Fikser litt på testene til Robot

This commit is contained in:
Kristian Knarvik 2020-02-25 16:55:35 +01:00
parent eb3199b5fd
commit fe42257cb4

View File

@ -10,61 +10,69 @@ import org.junit.Test;
public class RobotTest {
private Position robotPosition;
private Robot testRobot;
private int nextFlag = 1;
@Before
public void setUp(){
public void setUp() {
robotPosition = new Position(3,6);
testRobot = new Robot(RobotID.ROBOT_6, robotPosition);
}
@Test
public void testRobotGetDamageOnInitializedRobot(){
assertEquals(0, testRobot.getDamage());
assertEquals(0, testRobot.getDamageTaken());
}
@Test
public void testRobotGetPlayerId(){
assertEquals(RobotID.ROBOT_6, testRobot.getRobotId());
}
@Test
public void testRobotGetBackupOnInitializedRobot(){
assertEquals(robotPosition, testRobot.getBackupPosition());
}
@Test
public void testRobotSetDamage(){
testRobot.setDamage(2);
assertEquals(2, testRobot.getDamage());
public void testRobotSetDamage() {
testRobot.setDamageTaken(2);
assertEquals(2, testRobot.getDamageTaken());
}
@Test
public void testRobotGetPositionOnInitializedRobot(){
assertEquals(robotPosition, testRobot.getPosition());
}
@Test
public void testRobotGetPositionOnRobotWithNewPosition(){
public void testRobotGetPositionOnRobotWithNewPosition() {
Position newRobotPosition = new Position(8,12);
testRobot.setPosition(newRobotPosition);
assertEquals(newRobotPosition, testRobot.getPosition());
}
@Test
public void testRobotIsInPowerDownOnInitializedRobot(){
assertEquals(false, testRobot.isInPowerDown());
}
@Test
public void testRobotSetPowerDown(){
public void testRobotSetPowerDown() {
testRobot.setPowerDown(true);
assertEquals(true, testRobot.isInPowerDown());
}
@Test
public void testRobotGetNewFlag(){
int nextFlag = 2;
Position nextFlagPosition = new Position(3,4);
testRobot.setLastFlagVisitedAndBackupPosition(nextFlag,nextFlagPosition);
assertEquals(2, testRobot.getLastFlagVisited());
public void testRobotGetNewFlag() {
testRobot.setLastFlagVisitedAndUpdateBackupPosition(nextFlag);
assertEquals(1, testRobot.getLastFlagVisited());
}
@Test
public void testRobotGetNewBackup(){
int nextFlag = 2;
public void testRobotGetNewBackup() {
Position nextFlagPosition = new Position(3,4);
testRobot.setLastFlagVisitedAndBackupPosition(nextFlag,nextFlagPosition);
testRobot.setPosition(nextFlagPosition);
testRobot.setLastFlagVisitedAndUpdateBackupPosition(nextFlag);
assertEquals(nextFlagPosition, testRobot.getBackupPosition());
}
}