Made RobotTest more readable

This commit is contained in:
Tobydrama 2020-02-22 14:16:55 +01:00
parent a30018dee4
commit 0dac36a6ea

View File

@ -1,68 +1,60 @@
package inf112.fiasko.roborally.objects;
import inf112.fiasko.roborally.element_properties.Position;
import inf112.fiasko.roborally.objects.Robot;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
public class RobotTest {
private Position robotPosition;
private Robot testRobot;
@Before
public void setUp(){
robotPosition = new Position(3,6);
testRobot = new Robot(6, robotPosition);
}
@Test
public void testRobotGetDamageOnInitializedRobot(){
Position robotPosition = new Position(3,6);
Robot testRobotGetDamage = new Robot(6, robotPosition);
assertEquals(0, testRobotGetDamage.getDamage());
assertEquals(0, testRobot.getDamage());
}
@Test
public void testRobotSetDamage(){
Position robotPosition = new Position(3,6);
Robot testRobotSetDamage = new Robot(6, robotPosition);
testRobotSetDamage.setDamage(2);
assertEquals(2, testRobotSetDamage.getDamage());
testRobot.setDamage(2);
assertEquals(2, testRobot.getDamage());
}
@Test
public void testRobotGetPositionOnInitializedRobot(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
assertEquals(robotPosition, testRobotGetPosition.getPosition());
assertEquals(robotPosition, testRobot.getPosition());
}
@Test
public void testRobotGetPositionOnNewPosition(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
public void testRobotGetPositionOnRobotWithNewPosition(){
Position newRobotPosition = new Position(8,12);
testRobotGetPosition.setPosition(newRobotPosition);
assertEquals(newRobotPosition, testRobotGetPosition.getPosition());
testRobot.setPosition(newRobotPosition);
assertEquals(newRobotPosition, testRobot.getPosition());
}
@Test
public void testRobotIsInPowerDownOnInitializedRobot(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
assertEquals(false, testRobotGetPosition.isInPowerDown());
assertEquals(false, testRobot.isInPowerDown());
}
@Test
public void testRobotSetPowerDown(){
Position robotPosition = new Position(3,6);
Robot testRobotGetPosition = new Robot(6, robotPosition);
testRobotGetPosition.setPowerDown(true);
assertEquals(true, testRobotGetPosition.isInPowerDown());
testRobot.setPowerDown(true);
assertEquals(true, testRobot.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());
testRobot.setLastFlagVisitedAndBackupPosition(nextFlag,nextFlagPosition);
assertEquals(2, testRobot.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());
testRobot.setLastFlagVisitedAndBackupPosition(nextFlag,nextFlagPosition);
assertEquals(nextFlagPosition, testRobot.getBackupPosition());
}