mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-08 02:59:36 +01:00
added and altered some test in PlayerTest
This commit is contained in:
parent
bbfbdb0539
commit
7bc24ff03e
@ -4,106 +4,76 @@ import inf112.fiasko.roborally.element_properties.Action;
|
|||||||
import inf112.fiasko.roborally.element_properties.RobotID;
|
import inf112.fiasko.roborally.element_properties.RobotID;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|
||||||
public class PlayerTest {
|
public class PlayerTest {
|
||||||
private Player playerTest;
|
private Player playerTest;
|
||||||
|
private List<ProgrammingCard> cards = new ArrayList();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
List<ProgrammingCard> cards = new ArrayList();
|
|
||||||
cards.add(new ProgrammingCard(10, Action.MOVE_1));
|
cards.add(new ProgrammingCard(10, Action.MOVE_1));
|
||||||
cards.add(new ProgrammingCard(20, Action.MOVE_2));
|
cards.add(new ProgrammingCard(20, Action.MOVE_2));
|
||||||
cards.add(new ProgrammingCard(30, Action.MOVE_3));
|
cards.add(new ProgrammingCard(30, Action.MOVE_3));
|
||||||
cards.add(new ProgrammingCard(40, Action.BACK_UP));
|
cards.add(new ProgrammingCard(40, Action.BACK_UP));
|
||||||
cards.add(new ProgrammingCard(50, Action.ROTATE_LEFT));
|
cards.add(new ProgrammingCard(50, Action.ROTATE_LEFT));
|
||||||
ProgrammingCardDeck playerDeck = new ProgrammingCardDeck(cards);
|
ProgrammingCardDeck playerDeck = new ProgrammingCardDeck(cards);
|
||||||
playerTest = new Player(RobotID.ROBOT_1, "TestPlayer" ,playerDeck);
|
playerTest = new Player(RobotID.ROBOT_1, "TestPlayer" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setPowerDownStatusToTrue() {
|
public void setPowerDownStatusToTrue() {
|
||||||
playerTest.setPowerDownNextRound(true);
|
playerTest.setPowerDownNextRound(true);
|
||||||
assertEquals(true, playerTest.getPowerDownNextRound());
|
assertTrue(playerTest.getPowerDownNextRound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setPowerDownStatusToFalse() {
|
public void setPowerDownStatusToFalse() {
|
||||||
playerTest.setPowerDownNextRound(false);
|
playerTest.setPowerDownNextRound(false);
|
||||||
assertEquals(false, playerTest.getPowerDownNextRound());
|
assertFalse(playerTest.getPowerDownNextRound());
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void cardGetsInsertedIntoProgram() {
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1));
|
|
||||||
assertEquals(Action.MOVE_1,playerTest.getProgram().get(0).getAction());
|
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void addMultipuleCards(){
|
public void testSetInProgram(){
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1));
|
playerTest.setInProgram(cards);
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(30,Action.MOVE_2));
|
assertEquals(Action.MOVE_1, playerTest.getProgramFromPlayer().get(0).getAction());
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(23452342,Action.MOVE_3));
|
assertEquals(Action.MOVE_2, playerTest.getProgramFromPlayer().get(1).getAction());
|
||||||
assertEquals(Action.MOVE_1,playerTest.getProgram().get(0).getAction());
|
assertEquals(Action.MOVE_3, playerTest.getProgramFromPlayer().get(2).getAction());
|
||||||
assertEquals(Action.MOVE_2,playerTest.getProgram().get(1).getAction());
|
assertEquals(Action.BACK_UP, playerTest.getProgramFromPlayer().get(3).getAction());
|
||||||
assertEquals(Action.MOVE_3,playerTest.getProgram().get(2).getAction());
|
|
||||||
}
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void addTooManyCardsGetsAError() {
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(30,Action.MOVE_2));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(234523423,Action.MOVE_3));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(2342342,Action.MOVE_3));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(23432342,Action.MOVE_3));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(234523242,Action.MOVE_3));
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void removeCardsFromPlayerProgram() {
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(30,Action.MOVE_2));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(234523423,Action.MOVE_3));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(2342342,Action.MOVE_3));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(23432342,Action.MOVE_3));
|
|
||||||
assertEquals(Action.MOVE_3,playerTest.getProgram().get(4).getAction());
|
|
||||||
playerTest.removeProgramCard(4);
|
|
||||||
assertEquals(null,playerTest.getProgram().get(4));
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void removeAllCardsFromPlayerProgram() {
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(30,Action.MOVE_2));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(234523423,Action.MOVE_3));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(2342342,Action.MOVE_3));
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(23432342,Action.MOVE_3));
|
|
||||||
assertEquals(Action.MOVE_3,playerTest.getProgram().get(4).getAction());
|
|
||||||
assertEquals(Action.MOVE_3,playerTest.getProgram().get(3).getAction());
|
|
||||||
assertEquals(Action.MOVE_3,playerTest.getProgram().get(2).getAction());
|
|
||||||
assertEquals(Action.MOVE_2,playerTest.getProgram().get(1).getAction());
|
|
||||||
assertEquals(Action.MOVE_1,playerTest.getProgram().get(0).getAction());
|
|
||||||
playerTest.removeProgramCard(4);
|
|
||||||
playerTest.removeProgramCard(3);
|
|
||||||
playerTest.removeProgramCard(2);
|
|
||||||
playerTest.removeProgramCard(1);
|
|
||||||
playerTest.removeProgramCard(0);
|
|
||||||
assertEquals(null,playerTest.getProgram().get(4));
|
|
||||||
assertEquals(null,playerTest.getProgram().get(3));
|
|
||||||
assertEquals(null,playerTest.getProgram().get(2));
|
|
||||||
assertEquals(null,playerTest.getProgram().get(1));
|
|
||||||
assertEquals(null,playerTest.getProgram().get(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test (expected = IllegalArgumentException.class)
|
@Test (expected = IllegalArgumentException.class)
|
||||||
public void getErrorIfYouRemoveMoreThenIndexFive(){
|
public void testSetInProgramWithToManyCards(){
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1));
|
cards.add(new ProgrammingCard(10,Action.ROTATE_LEFT));
|
||||||
playerTest.removeProgramCard(5);
|
playerTest.setInProgram(cards);
|
||||||
|
|
||||||
}
|
}
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void getErrorIfYouRemoveANegativIndex(){
|
|
||||||
playerTest.setCardInProgram(new ProgrammingCard(10,Action.MOVE_1));
|
|
||||||
playerTest.removeProgramCard(-1);
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetInDeck(){
|
||||||
|
cards.add(new ProgrammingCard(10,Action.ROTATE_LEFT));
|
||||||
|
ProgrammingCardDeck playerDeck = new ProgrammingCardDeck(cards);
|
||||||
|
playerTest.setPlayerDeck(playerDeck);
|
||||||
|
assertEquals(playerDeck , playerTest.getPlayerDeck());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void GetPlayerRobotId(){
|
||||||
|
assertEquals(RobotID.ROBOT_1, playerTest.getRobotID());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void GetPlayerName(){
|
||||||
|
assertEquals("TestPlayer", playerTest.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void GetProgramFromPlayer(){
|
||||||
|
playerTest.setInProgram(cards);
|
||||||
|
assertEquals(cards,playerTest.getProgram());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user