From cc3c752612a4130fa628664304e3af00d56fc365 Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Tue, 11 Jan 2022 09:18:54 +0100 Subject: [PATCH] Add Gameboard.java and GameboardTest.java --- src/main/java/Gameboard.java | 8 +++++++ src/test/java/GameboardTest.java | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/main/java/Gameboard.java create mode 100644 src/test/java/GameboardTest.java diff --git a/src/main/java/Gameboard.java b/src/main/java/Gameboard.java new file mode 100644 index 0000000..9dc4cd4 --- /dev/null +++ b/src/main/java/Gameboard.java @@ -0,0 +1,8 @@ +public class Gameboard { + int[][] board; + + public Gameboard() { + board = new int[11][11]; + } + +} diff --git a/src/test/java/GameboardTest.java b/src/test/java/GameboardTest.java new file mode 100644 index 0000000..f5b38ac --- /dev/null +++ b/src/test/java/GameboardTest.java @@ -0,0 +1,36 @@ +import static org.assertj.core.api.Assertions.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class GameboardTest { + + private Gameboard gb; + + @BeforeEach + void setup() { + gb = new Gameboard(); + } + + @Test + void checkGameboardSize() { + String expectedResult = "11, 11"; + String currentResult = "" + gb.board.length + ", " + gb.board[0].length; + + assertThat(currentResult).describedAs("Dimensions").isEqualTo(expectedResult); + } + + @Test + void checkGameboardFilled() { + int[][] expectedGameboard = new int[11][11]; + for(int i = 0; i < expectedGameboard.length; i++) { + for(int j = 0; j < expectedGameboard[0].length; j++) { + expectedGameboard[i][j] = 0; + } + } + int [][] givenGameboard = gb.board; + + assertThat(givenGameboard).describedAs("Initial Gameboard").isEqualTo(expectedGameboard); + } + +}