|
@ -1,16 +1,23 @@ |
|
|
package de.tims.fleetstorm; |
|
|
package de.tims.fleetstorm; |
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
class GameManagerTest { |
|
|
class GameManagerTest { |
|
|
|
|
|
|
|
|
GameManager gameManager = new GameManager(); |
|
|
GameManager gameManager = new GameManager(); |
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
|
|
void setup() { |
|
|
|
|
|
gameManager.start(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void testIfGameStateIsPreparationAfterStart() { |
|
|
void testIfGameStateIsPreparationAfterStart() { |
|
|
gameManager.start(); |
|
|
|
|
|
int expectedState = GameManager.PREPARATION; |
|
|
int expectedState = GameManager.PREPARATION; |
|
|
|
|
|
|
|
|
int calculatedState = gameManager.getGameState(); |
|
|
int calculatedState = gameManager.getGameState(); |
|
@ -18,4 +25,19 @@ class GameManagerTest { |
|
|
assertEquals(expectedState, calculatedState); |
|
|
assertEquals(expectedState, calculatedState); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void testNextMoveIsNotPlayer() { |
|
|
|
|
|
|
|
|
|
|
|
// 20 tries => every even move is a player move |
|
|
|
|
|
for (int i = 0; i < 20; i++) { |
|
|
|
|
|
gameManager.nextMove(); |
|
|
|
|
|
boolean calculatedResult = gameManager.isPlayerMove(); |
|
|
|
|
|
if (i % 2 == 0) { |
|
|
|
|
|
assertFalse(calculatedResult); |
|
|
|
|
|
} else { |
|
|
|
|
|
assertTrue(calculatedResult); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |