Browse Source

Added GameManager and check if GameState is correct after start function call

tictactoe
Lorenz Hohmann 3 years ago
parent
commit
2c299f689a
  1. 19
      src/main/java/de/tims/fleetstorm/GameManager.java
  2. 21
      src/test/java/de/tims/fleetstorm/GameManagerTest.java

19
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;
}
}

21
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);
}
}
Loading…
Cancel
Save