From 8b31b76e696a382faf8e9e8fa75ed882a4ad7be9 Mon Sep 17 00:00:00 2001 From: Malte Schellhardt Date: Wed, 9 Feb 2022 15:25:43 +0100 Subject: [PATCH] tictactoe: added test case for player 2 in playfield setter --- src/main/java/de/tims/tictactoe/GameLogic.java | 4 ++-- src/test/java/de/tims/tictactoe/GameLogicTest.java | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/tims/tictactoe/GameLogic.java b/src/main/java/de/tims/tictactoe/GameLogic.java index 91d3e36..5bd2a48 100644 --- a/src/main/java/de/tims/tictactoe/GameLogic.java +++ b/src/main/java/de/tims/tictactoe/GameLogic.java @@ -25,8 +25,8 @@ public class GameLogic { return this.board[0].length * this.board.length; } - public void setField(int row, int column, char player) { - this.board[row][column] = player; + public void setField(int column, int row, char player) { + this.board[column][row] = player; } } diff --git a/src/test/java/de/tims/tictactoe/GameLogicTest.java b/src/test/java/de/tims/tictactoe/GameLogicTest.java index 6810b9a..8a22db9 100644 --- a/src/test/java/de/tims/tictactoe/GameLogicTest.java +++ b/src/test/java/de/tims/tictactoe/GameLogicTest.java @@ -55,8 +55,8 @@ class GameLogicTest { @ParameterizedTest(name = "[{index}] {0}") @MethodSource("testCasesForSetField") - void setFieldTest(String testName, int row, int column, char player, char[][] expectedResult) { - this.game.setField(row, column, player); + void setFieldTest(String testName, int column, int row, char player, char[][] expectedResult) { + this.game.setField(column, row, player); char[][] realResult = this.game.getBoard(); assertArrayEquals(expectedResult, realResult); @@ -77,7 +77,11 @@ class GameLogicTest { Arguments.of("set field [0][0] for player 1", 0, 0, 'x', new char[][] {{'x', '-', '-'}, {'-', '-', '-'}, - {'-', '-', '-'}}) + {'-', '-', '-'}}), + Arguments.of("set field [1][0] for player 2", 1, 0, 'o', new char[][] + {{'-', '-', '-'}, + {'o', '-', '-'}, + {'-', '-', '-'}}) ); }