Code Cleanup

This commit is contained in:
romanschenk37
2022-03-25 20:57:07 +01:00
parent a9366de7bc
commit 29b9daadd4
5 changed files with 50 additions and 29 deletions
@@ -6,9 +6,9 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
@@ -179,7 +179,7 @@ class CarTest {
assertEquals(moveStrategy, car.getMoveStrategy());
try {
moveStrategy = new MoveListStrategy(".\\moves\\challenge-car-a.txt");
moveStrategy = new MoveListStrategy(new File(".\\moves\\challenge-car-a.txt"));
} catch (FileNotFoundException e) {
Assertions.fail();
}
@@ -187,7 +187,7 @@ class CarTest {
assertEquals(moveStrategy, car.getMoveStrategy());
try {
moveStrategy = new PathFollowerMoveStrategy(".\\follower\\challenge_points.txt", new PositionVector(0, 0));
moveStrategy = new PathFollowerMoveStrategy(new File(".\\follower\\challenge_points.txt"), new PositionVector(0, 0));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
@@ -32,7 +32,8 @@ class GameTest {
@BeforeEach
void setup() {
userInterface = new UserInterface("Test");
game = new Game(userInterface);
Config config = new Config();
game = new Game(userInterface, config);
try {
track = game.selectTrack(new File(TRACK_FILE_PATH));
} catch (InvalidTrackFormatException | FileNotFoundException e) {
@@ -95,7 +96,8 @@ class GameTest {
@BeforeEach
void setup() {
userInterface = new UserInterface("Test");
game = new Game(userInterface);
Config config = new Config();
game = new Game(userInterface, config);
try {
track = game.selectTrack(new File(TRACK_FILE_PATH));
} catch (InvalidTrackFormatException | FileNotFoundException e) {
@@ -169,21 +171,21 @@ class GameTest {
UP_RIGHT,
UP_RIGHT,
RIGHT,
RIGHT}));
RIGHT}), new Config());
game.initPhase();
Assertions.assertEquals("a",game.gamePhase());
}
@Test
void crashA() {
game = new Game(new interFace("Test",new Integer[]{0,1,0},new PositionVector.Direction[]{UP}));
game = new Game(new interFace("Test",new Integer[]{0,1,0},new PositionVector.Direction[]{UP}), new Config());
game.initPhase();
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 = 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());
}
@@ -4,6 +4,7 @@ import ch.zhaw.pm2.racetrack.strategy.MoveListStrategy;
import ch.zhaw.pm2.racetrack.strategy.MoveStrategy;
import org.junit.jupiter.api.*;
import java.io.File;
import java.io.FileNotFoundException;
public class MoveStrategyTest {
@@ -18,7 +19,7 @@ public class MoveStrategyTest {
@BeforeEach
void setup() {
try {
moveList = new MoveListStrategy(".\\moves\\challenge-car-a.txt");
moveList = new MoveListStrategy(new File(".\\moves\\challenge-car-a.txt"));
}catch (FileNotFoundException e) {
e.printStackTrace();
}