Merge remote-tracking branch 'origin/main'
This commit is contained in:
		
						commit
						31c76273c9
					
				| 
						 | 
					@ -10,14 +10,18 @@ import java.io.FileNotFoundException;
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * This Class tests the MoveStrategy.
 | 
					 * This Class tests the MoveStrategy.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class MoveStrategyTest {
 | 
					public class MoveListStrategyTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private MoveStrategy moveList;
 | 
					    private MoveStrategy moveList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Nested
 | 
					    @Nested
 | 
				
			||||||
    @DisplayName("MoveListStrategy")
 | 
					    @DisplayName("MoveListStrategy")
 | 
				
			||||||
    class MoveList {
 | 
					    class MoveList {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Creates a new MoveListStrategy
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @BeforeEach
 | 
					        @BeforeEach
 | 
				
			||||||
        void setup() {
 | 
					        void setup() {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
| 
						 | 
					@ -27,6 +31,9 @@ public class MoveStrategyTest {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Checks if the directions are returned correct by method nextMove
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        void checkMove() {
 | 
					        void checkMove() {
 | 
				
			||||||
            Assertions.assertEquals(PositionVector.Direction.RIGHT,moveList.nextMove());
 | 
					            Assertions.assertEquals(PositionVector.Direction.RIGHT,moveList.nextMove());
 | 
				
			||||||
| 
						 | 
					@ -14,8 +14,8 @@ public class TrackTest {
 | 
				
			||||||
    Track trackObj;
 | 
					    Track trackObj;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Nested
 | 
					    @Nested
 | 
				
			||||||
    @DisplayName("Positiv Test Cases")
 | 
					    @DisplayName("Positive Test Cases")
 | 
				
			||||||
    class positivClass {
 | 
					    class positiveClass {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @BeforeEach
 | 
					        @BeforeEach
 | 
				
			||||||
        void setup() {
 | 
					        void setup() {
 | 
				
			||||||
| 
						 | 
					@ -29,12 +29,18 @@ public class TrackTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Checks if correct amount of cars has been instantiated
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Create correct amount of Car instance")
 | 
					        @DisplayName("Create correct amount of Car instance")
 | 
				
			||||||
        void checkCars() {
 | 
					        void checkCars() {
 | 
				
			||||||
            Assertions.assertEquals(2, trackObj.getCarCount());
 | 
					            Assertions.assertEquals(2, trackObj.getCarCount());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Checks if car id matches track file symbol
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Create Car instance with correct Symbols / Id")
 | 
					        @DisplayName("Create Car instance with correct Symbols / Id")
 | 
				
			||||||
        void checkCarId() {
 | 
					        void checkCarId() {
 | 
				
			||||||
| 
						 | 
					@ -42,13 +48,18 @@ public class TrackTest {
 | 
				
			||||||
            Assertions.assertEquals('b', trackObj.getCarId(1));
 | 
					            Assertions.assertEquals('b', trackObj.getCarId(1));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * checks if track reads space typ from track file correctly
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Check getSpaceTyp")
 | 
					        @DisplayName("Check getSpaceTyp")
 | 
				
			||||||
        void getSpaceTyp() {
 | 
					        void getSpaceTyp() {
 | 
				
			||||||
            Assertions.assertEquals(ConfigSpecification.SpaceType.FINISH_RIGHT, trackObj.getSpaceType(new PositionVector(22, 24)));
 | 
					            Assertions.assertEquals(ConfigSpecification.SpaceType.FINISH_RIGHT, trackObj.getSpaceType(new PositionVector(22, 24)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * checks if track finds the finish line at the correct positions
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Find FinishLine")
 | 
					        @DisplayName("Find FinishLine")
 | 
				
			||||||
        void findFinish() {
 | 
					        void findFinish() {
 | 
				
			||||||
| 
						 | 
					@ -59,6 +70,9 @@ public class TrackTest {
 | 
				
			||||||
            Assertions.assertEquals(expected, trackObj.getFinishLine());
 | 
					            Assertions.assertEquals(expected, trackObj.getFinishLine());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Checks if track does read in track file correctly
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Converts track file correctly to List<String>")
 | 
					        @DisplayName("Converts track file correctly to List<String>")
 | 
				
			||||||
        void checkTrack() {
 | 
					        void checkTrack() {
 | 
				
			||||||
| 
						 | 
					@ -86,6 +100,9 @@ public class TrackTest {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * checks if track does process car move correctly
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Make Car move down on track")
 | 
					        @DisplayName("Make Car move down on track")
 | 
				
			||||||
        void makeCarMoveDown() {
 | 
					        void makeCarMoveDown() {
 | 
				
			||||||
| 
						 | 
					@ -97,6 +114,9 @@ public class TrackTest {
 | 
				
			||||||
            Assertions.assertEquals(beforeMove.getX(), afterMove.getX());
 | 
					            Assertions.assertEquals(beforeMove.getX(), afterMove.getX());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Checks if car does not move if there is no acceleration
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Make Car move with (0,0) acceleration on track")
 | 
					        @DisplayName("Make Car move with (0,0) acceleration on track")
 | 
				
			||||||
        void makeCarStay() {
 | 
					        void makeCarStay() {
 | 
				
			||||||
| 
						 | 
					@ -107,6 +127,9 @@ public class TrackTest {
 | 
				
			||||||
            Assertions.assertEquals(beforeMove.getX(), afterMove.getX());
 | 
					            Assertions.assertEquals(beforeMove.getX(), afterMove.getX());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Checks if car does crash
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Will Car Crash")
 | 
					        @DisplayName("Will Car Crash")
 | 
				
			||||||
        void willCarCrash() {
 | 
					        void willCarCrash() {
 | 
				
			||||||
| 
						 | 
					@ -119,6 +142,9 @@ public class TrackTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * checks if track is updated after car crash
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Make Car Crash")
 | 
					        @DisplayName("Make Car Crash")
 | 
				
			||||||
        void makeCarCrash() {
 | 
					        void makeCarCrash() {
 | 
				
			||||||
| 
						 | 
					@ -128,10 +154,14 @@ public class TrackTest {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * This testcase does check for negative test cases
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    @Nested
 | 
					    @Nested
 | 
				
			||||||
    @DisplayName("Negative TestCase")
 | 
					    @DisplayName("Negative TestCase")
 | 
				
			||||||
    class negativeClass {
 | 
					    class negativeClass {
 | 
				
			||||||
        File file;
 | 
					        File file;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @BeforeEach
 | 
					        @BeforeEach
 | 
				
			||||||
        void setup() {
 | 
					        void setup() {
 | 
				
			||||||
            file = new File(".\\tracks\\challenge.txt");
 | 
					            file = new File(".\\tracks\\challenge.txt");
 | 
				
			||||||
| 
						 | 
					@ -143,6 +173,9 @@ public class TrackTest {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Tries to read not valid file
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Throw error if File not found")
 | 
					        @DisplayName("Throw error if File not found")
 | 
				
			||||||
        void canReadFile() {
 | 
					        void canReadFile() {
 | 
				
			||||||
| 
						 | 
					@ -150,6 +183,9 @@ public class TrackTest {
 | 
				
			||||||
            Assertions.assertThrows(FileNotFoundException.class, () -> new Track(file));
 | 
					            Assertions.assertThrows(FileNotFoundException.class, () -> new Track(file));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /**
 | 
				
			||||||
 | 
					         * Tries to read not valid file with 2 cars with same symbol
 | 
				
			||||||
 | 
					         */
 | 
				
			||||||
        @Test
 | 
					        @Test
 | 
				
			||||||
        @DisplayName("Throw error if File is invalid")
 | 
					        @DisplayName("Throw error if File is invalid")
 | 
				
			||||||
        void invalidTrackFile() {
 | 
					        void invalidTrackFile() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue