- updated javadoc
- added playscenario to GameTest
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
package ch.zhaw.pm2.racetrack;
|
||||
|
||||
import ch.zhaw.pm2.racetrack.strategy.UserMoveStrategy;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
@@ -14,7 +11,7 @@ import static ch.zhaw.pm2.racetrack.PositionVector.Direction.*;
|
||||
|
||||
|
||||
/**
|
||||
* Test for Class Game
|
||||
* Test for Class Game. The Class is split up in nested classes.
|
||||
*/
|
||||
class GameTest {
|
||||
private UserInterface userInterface;
|
||||
@@ -26,7 +23,7 @@ class GameTest {
|
||||
private final int CAR_INDEX_TWO = 1;
|
||||
|
||||
/**
|
||||
* This nested Class tests if the game gets initiatet correctly
|
||||
* This nested Class tests if the game gets initiatet correctly.
|
||||
*/
|
||||
@Nested
|
||||
@DisplayName("Test correct Setup")
|
||||
@@ -124,7 +121,8 @@ class GameTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* This nested Class tests a Playtrough. And implements a UserInterface interagtion to pretend a real player
|
||||
* This nested Class tests a playtrough and implements a userInterface which pretends to be a real player.
|
||||
* At the end of every Test the Userinterface stays open for 10 more sec to visualize the game.
|
||||
*/
|
||||
@Nested
|
||||
@DisplayName("Playtrough")
|
||||
@@ -183,8 +181,28 @@ class GameTest {
|
||||
Assertions.assertEquals("b",game.gamePhase());
|
||||
}
|
||||
|
||||
@Test
|
||||
void passFinishLineInWrongDirection() {
|
||||
game = new Game(new interFace("Test",new Integer[]{1,0,1},new PositionVector.Direction[]{LEFT,NONE,NONE,RIGHT,RIGHT}));
|
||||
game.initPhase();
|
||||
Assertions.assertEquals("a",game.gamePhase());
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanUp() {
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 PositionVector.Direction[] directions;
|
||||
@@ -210,9 +228,6 @@ class GameTest {
|
||||
public void printInformation(String text) {
|
||||
}
|
||||
|
||||
public void printTrack(Track track) {
|
||||
}
|
||||
|
||||
public void quit(String text) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user