Merge remote-tracking branch 'origin/main'

This commit is contained in:
Andrin Fassbind
2022-03-25 23:45:03 +01:00
4 changed files with 34 additions and 22 deletions
@@ -14,7 +14,9 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
/**
* Tests for Class Car
* Class that contains all test for the Class Car
*
* @author Roman Schenk
*/
class CarTest {
@@ -26,7 +28,7 @@ class CarTest {
final char DEFAULT_ID = 'f';
/**
* Create a new Car Object and set Position to a defined Default Position
* Creates a new Car Object and set Position to a defined Default Position
*/
@BeforeEach
void setUp() {
@@ -34,7 +36,7 @@ class CarTest {
}
/**
* Checks getID
* Checks if the method getID returns the correct value
*/
@Test
void getID() {
@@ -52,8 +54,8 @@ class CarTest {
}
/**
* - checks if the position of the car can be set and saved correctly with valid positions.
* - checks if an exception is thrown and position keeps unchanged if invalid coordinates are entered.
* Checks if the position of the car can be set and saved correctly with valid positions.
* Checks if an exception is thrown and position kept unchanged if invalid coordinates are entered.
*/
@Test
void setPosition() {
@@ -159,7 +161,8 @@ class CarTest {
/**
* test for methods crash and isCrashed. checks if state crashed is set and returned correctly.
* Test for methods crash and isCrashed.
* Checks if state crashed is set and returned correctly.
*/
@Test
void crash() {
@@ -169,8 +172,8 @@ class CarTest {
}
/**
* test for methods setMoveStrategy. Checks if the MoveStrategy Object is saved and returned correctly
* with all Types of MoveStrategy.
* Test for methods setMoveStrategy.
* Checks if the MoveStrategy Object is saved and returned correctly with all Types of MoveStrategy.
*/
@Test
void MoveStrategy() {
@@ -202,7 +205,7 @@ class CarTest {
}
/**
* Test for get WinPoints
* Tests if getWinPoints returns the correct value.
*/
@Test
void getWinPoints() {
@@ -210,7 +213,7 @@ class CarTest {
}
/**
* Test for increase WinPoints
* Tests if winpoints increase functions properly.
*/
@Test
void increaseWinPoints() {
@@ -219,7 +222,7 @@ class CarTest {
}
/**
* Test for deduct WinPoints
* Tests if the deductions of winpoints functions properly.
*/
@Test
void deductWinPoints() {
@@ -160,7 +160,7 @@ class GameTest {
*/
@Test
void winner() {
game = new Game(new interFace("Test",new Integer[]{0,2,0},new PositionVector.Direction[]{RIGHT,
game = new Game(new Interface("Test",new Integer[]{0,2,0},new PositionVector.Direction[]{RIGHT,
RIGHT,
RIGHT,
NONE,
@@ -208,7 +208,7 @@ class GameTest {
*/
@Test
void crashA() {
game = new Game(new interFace("Test",new Integer[]{0,1,0},new PositionVector.Direction[]{UP}), new Config());
game = new Game(new Interface("Test",new Integer[]{0,1,0},new PositionVector.Direction[]{UP}), new Config());
game.initPhase();
Assertions.assertEquals("b",game.gamePhase());
}
@@ -218,7 +218,7 @@ class GameTest {
*/
@Test
void passFinishLineInWrongDirection() {
game = new Game(new interFace("Test",new Integer[]{1,0,1},new PositionVector.Direction[]{LEFT,NONE,NONE,RIGHT,RIGHT}), new Config());
game = new Game(new Interface("Test",new Integer[]{1,0,1},new PositionVector.Direction[]{LEFT,NONE,NONE,RIGHT,RIGHT}), new Config());
game.initPhase();
Assertions.assertEquals("a",game.gamePhase());
}
@@ -241,15 +241,15 @@ class GameTest {
* This Class is used to communicate with the UserInterface. It overrides crucial methods and returns an instruction based on the instructions' data field.
* To implement the right instructions the user has to be aware of the game sequence.
*/
private class interFace extends UserInterface {
private class Interface extends UserInterface {
private final PositionVector.Direction[] directions;
private final Integer[] instructions;
private int pointerDir,pointerInstruction;
public interFace(String welcometxt, Integer[] instructions, PositionVector.Direction[] directions) {
super(welcometxt);
public Interface(String welcometext, Integer[] instructions, PositionVector.Direction[] directions) {
super(welcometext);
pointerDir = -1;
pointerInstruction = -1;
this.instructions = instructions;
@@ -10,14 +10,18 @@ import java.io.FileNotFoundException;
/**
* This Class tests the MoveStrategy.
*/
public class MoveStrategyTest {
public class MoveListStrategyTest {
private MoveStrategy moveList;
@Nested
@DisplayName("MoveListStrategy")
class MoveList {
/**
* Creates a new MoveListStrategy
*/
@BeforeEach
void setup() {
try {
@@ -27,6 +31,9 @@ public class MoveStrategyTest {
}
}
/**
* Checks if the directions are returned correct by method nextMove
*/
@Test
void checkMove() {
Assertions.assertEquals(PositionVector.Direction.RIGHT,moveList.nextMove());