diff --git a/src/main/java/de/tims/tictactoe/GameLogic.java b/src/main/java/de/tims/tictactoe/GameLogic.java index 5bd2a48..ffa8b21 100644 --- a/src/main/java/de/tims/tictactoe/GameLogic.java +++ b/src/main/java/de/tims/tictactoe/GameLogic.java @@ -3,6 +3,7 @@ package de.tims.tictactoe; public class GameLogic { private char[][] board; + private final char emptyField = '-'; public GameLogic(int size) { if (size < 3) { @@ -26,7 +27,12 @@ public class GameLogic { } public void setField(int column, int row, char player) { - this.board[column][row] = player; + this.board[column][row] = player; + } + + public boolean fieldIsEmpty(int column, int row) { + // TODO Auto-generated method stub + return true; } } diff --git a/src/test/java/de/tims/tictactoe/GameLogicTest.java b/src/test/java/de/tims/tictactoe/GameLogicTest.java index e6f93a6..bd2593b 100644 --- a/src/test/java/de/tims/tictactoe/GameLogicTest.java +++ b/src/test/java/de/tims/tictactoe/GameLogicTest.java @@ -60,6 +60,14 @@ class GameLogicTest { assertArrayEquals(expectedResult, realResult); } + @ParameterizedTest(name = "[{index}] {0}") + @MethodSource("testCasesForCheckEmptyField") + void fieldIsEmptyTest(String testName, int columnToCheck, int rowToCheck, boolean expectedResult, char[][] board) { + boolean realResult = this.game.fieldIsEmpty(columnToCheck, rowToCheck); + + assertEquals(expectedResult, realResult); + } + private static Stream testCasesForCountPlayfields() { return Stream.of( Arguments.of("1x1 board with too few fields", 1, 9), @@ -82,5 +90,14 @@ class GameLogicTest { {'-', '-', '-'}}) ); } + + private static Stream testCasesForCheckEmptyField() { + return Stream.of( + Arguments.of("check an empty field", 0, 0, true, new char[][] + {{'-', '-', '-'}, + {'-', '-', '-'}, + {'-', '-', '-'}}) + ); + } }