diff --git a/src/main/java/de/tims/tictactoe/ai/AIHard.java b/src/main/java/de/tims/tictactoe/ai/AIHard.java index 8aae93e..6891e94 100644 --- a/src/main/java/de/tims/tictactoe/ai/AIHard.java +++ b/src/main/java/de/tims/tictactoe/ai/AIHard.java @@ -55,4 +55,8 @@ public class AIHard implements TicTacToeAI { gl.setField(row, col, AI_CHAR); } } + + public int countCharsInRow(int index, char charToCount) { + return 0; + } } diff --git a/src/test/java/de/tims/tictactoe/ai/AIHardTest.java b/src/test/java/de/tims/tictactoe/ai/AIHardTest.java index 215a5a4..049e093 100644 --- a/src/test/java/de/tims/tictactoe/ai/AIHardTest.java +++ b/src/test/java/de/tims/tictactoe/ai/AIHardTest.java @@ -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 testCasesForCountCharsInRow() { + return Stream.of(Arguments.of("EmptyFieldReturns0", + new char[][] { {'-', '-', '-'}, {'-', '-', '-'}, {'-', '-', '-'} }, + 0, 'o', 0)); + } }