|
|
@ -3,6 +3,7 @@ package de.tims.tictactoe; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeAll; |
|
|
@ -35,9 +36,11 @@ class GameLogicTest { |
|
|
|
|
|
|
|
@Test |
|
|
|
void getBoardTest() { |
|
|
|
int[][] expectedResult = new int[3][3]; |
|
|
|
int[][] realResult = this.game.getBoard(); |
|
|
|
|
|
|
|
char[][] expectedResult = new char[][]{{'-', '-', '-'}, |
|
|
|
{'-', '-', '-'}, |
|
|
|
{'-', '-', '-'}}; |
|
|
|
char[][] realResult = this.game.getBoard(); |
|
|
|
|
|
|
|
assertArrayEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
@ -50,6 +53,15 @@ class GameLogicTest { |
|
|
|
assertEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest(name = "[{index}] {0}") |
|
|
|
@MethodSource("testCasesForSetField") |
|
|
|
void setFieldTest(String testName, int row, int column, char player, char[][] expectedResult) { |
|
|
|
this.game.setField(row, column, player); |
|
|
|
char[][] realResult = this.game.getBoard(); |
|
|
|
|
|
|
|
assertArrayEquals(expectedResult, realResult); |
|
|
|
} |
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForCountPlayfields() { |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("1x1 board with too few fields", 1, 9), |
|
|
@ -59,5 +71,14 @@ class GameLogicTest { |
|
|
|
Arguments.of("5x5 board with 25 playfields", 5,25) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForSetField() { |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("set field [0][0] for player 1", 0, 0, 'x', new char[][] |
|
|
|
{{'x', '-', '-'}, |
|
|
|
{'-', '-', '-'}, |
|
|
|
{'-', '-', '-'}}) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |