addad a lot more test for RobotTest

This commit is contained in:
Tobydrama 2020-02-22 14:10:50 +01:00
parent 3bd9681d22
commit a30018dee4
2 changed files with 63 additions and 0 deletions

View File

@ -82,4 +82,20 @@ public class Robot {
this.backupPosition=newBackupPosition;
}
/**
* Gets the correct flag the robot visited
* @return last visited flag
*/
public int getLastFlagVisited(){
return lastFlagVisited;
}
/**
* Gets the robots backup position
* @return robots backup position
*/
public Position getBackupPosition(){
return backupPosition;
}
}

View File

@ -19,4 +19,51 @@ public class RobotTest {
testRobotSetDamage.setDamage(2);
assertEquals(2, testRobotSetDamage.getDamage());
}
@Test
public void testRobotGetPositionOnInitializedRobot(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
assertEquals(robotPosition, testRobotGetPosition.getPosition());
}
@Test
public void testRobotGetPositionOnNewPosition(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
Position newRobotPosition = new Position(8,12);
testRobotGetPosition.setPosition(newRobotPosition);
assertEquals(newRobotPosition, testRobotGetPosition.getPosition());
}
@Test
public void testRobotIsInPowerDownOnInitializedRobot(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
assertEquals(false, testRobotGetPosition.isInPowerDown());
}
@Test
public void testRobotSetPowerDown(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
testRobotGetPosition.setPowerDown(true);
assertEquals(true, testRobotGetPosition.isInPowerDown());
}
@Test
public void testRobotGetNewFlag(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
int nextFlag = 2;
Position nextFlagPosition = new Position(3,4);
testRobotGetPosition.setLastFlagVisitedAndBackupPosition(nextFlag,nextFlagPosition);
assertEquals(2, testRobotGetPosition.getLastFlagVisited());
}
@Test
public void testRobotGetNewBackup(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
int nextFlag = 2;
Position nextFlagPosition = new Position(3,4);
testRobotGetPosition.setLastFlagVisitedAndBackupPosition(nextFlag,nextFlagPosition);
assertEquals(nextFlagPosition, testRobotGetPosition.getBackupPosition());
}
}