|
|
@ -1,9 +1,15 @@ |
|
|
|
package de.tims.tictactoe.ai; |
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.*; |
|
|
|
import static org.mockito.Mockito.*; |
|
|
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.jupiter.api.extension.ExtendWith; |
|
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
|
import org.mockito.Mock; |
|
|
|
import org.mockito.junit.jupiter.MockitoExtension; |
|
|
|
|
|
|
@ -59,5 +65,22 @@ class AIHardTest { |
|
|
|
|
|
|
|
verify(gl, times(1)).setField(0, 2, realChar); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("testCasesForCountCharsInRow") |
|
|
|
void countCharsInRowTest(String testName, char[][] board, int rowNum, char charToCount, int expectedResult) { |
|
|
|
doReturn(board).when(gl).getBoard(); |
|
|
|
|
|
|
|
AIHard ai = new AIHard(gl); |
|
|
|
int realResult = ai.countCharsInRow(rowNum, charToCount); |
|
|
|
|
|
|
|
assertThat(realResult).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForCountCharsInRow() { |
|
|
|
return Stream.of(Arguments.of("EmptyFieldReturns0", |
|
|
|
new char[][] { {'-', '-', '-'}, {'-', '-', '-'}, {'-', '-', '-'} }, |
|
|
|
0, 'o', 0)); |
|
|
|
} |
|
|
|
|
|
|
|
} |