|
|
@ -1,10 +1,16 @@ |
|
|
|
package de.tims.tictactoe; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeAll; |
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
|
|
|
|
|
class GameLogicTest { |
|
|
|
|
|
|
@ -35,12 +41,21 @@ class GameLogicTest { |
|
|
|
assertArrayEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void fieldCountTest() { |
|
|
|
int expectedResult = 9; |
|
|
|
int realResult = game.countFields(); |
|
|
|
|
|
|
|
assertEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
@ParameterizedTest(name = "[{index}] {0} -> {1}") |
|
|
|
@MethodSource("testCasesForCountPlayfields") |
|
|
|
void fieldCountTest(String testName, int size, int expectedResult) { |
|
|
|
GameLogic game = new GameLogic(size); |
|
|
|
int realResult = game.countFields(); |
|
|
|
|
|
|
|
assertEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForCountPlayfields() { |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("3x3 board with 9 playfields", 3, 9), |
|
|
|
Arguments.of("4x4 board with 16 playfields", 4, 16), |
|
|
|
Arguments.of("5x5 board with 25 playfields", 5,25) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |