From 557984b581229b14451bfdc726b581817544d882 Mon Sep 17 00:00:00 2001 From: Lorenz Hohmann Date: Wed, 12 Jan 2022 11:41:14 +0100 Subject: [PATCH] Added GameManager and check if GameState is correct after start function call --- .../java/de/tims/fleetstorm/GameManager.java | 19 +++++++++++++++++ .../de/tims/fleetstorm/GameManagerTest.java | 21 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/main/java/de/tims/fleetstorm/GameManager.java create mode 100644 src/test/java/de/tims/fleetstorm/GameManagerTest.java diff --git a/src/main/java/de/tims/fleetstorm/GameManager.java b/src/main/java/de/tims/fleetstorm/GameManager.java new file mode 100644 index 0000000..8f682cc --- /dev/null +++ b/src/main/java/de/tims/fleetstorm/GameManager.java @@ -0,0 +1,19 @@ +package de.tims.fleetstorm; + +public class GameManager { + + private int gameState; + + public static final int PREPARATION = 1; + public static final int RUNNING = 2; + public static final int OVER = 3; + + public void start() { + this.gameState = GameManager.PREPARATION; + } + + public int getGameState() { + return gameState; + } + +} diff --git a/src/test/java/de/tims/fleetstorm/GameManagerTest.java b/src/test/java/de/tims/fleetstorm/GameManagerTest.java new file mode 100644 index 0000000..d90e85f --- /dev/null +++ b/src/test/java/de/tims/fleetstorm/GameManagerTest.java @@ -0,0 +1,21 @@ +package de.tims.fleetstorm; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class GameManagerTest { + + GameManager gameManager = new GameManager(); + + @Test + void testIfGameStateIsPreparationAfterStart() { + gameManager.start(); + int expectedState = GameManager.PREPARATION; + + int calculatedState = gameManager.getGameState(); + + assertEquals(expectedState, calculatedState); + } + +}