mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
addad a lot more test for RobotTest
This commit is contained in:
parent
3bd9681d22
commit
a30018dee4
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user