|
@ -14,68 +14,55 @@ class GameManagerTest { |
|
|
void GameManager_Update_increasesTime() { |
|
|
void GameManager_Update_increasesTime() { |
|
|
// arrange |
|
|
// arrange |
|
|
GameManager gameManager = new GameManager(); |
|
|
GameManager gameManager = new GameManager(); |
|
|
|
|
|
|
|
|
// act |
|
|
// act |
|
|
|
|
|
|
|
|
int expectedUpdatedTime = gameManager.time + 1; |
|
|
int expectedUpdatedTime = gameManager.time + 1; |
|
|
gameManager.Update(); |
|
|
gameManager.Update(); |
|
|
int updatedTime = gameManager.time; |
|
|
int updatedTime = gameManager.time; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
// assert |
|
|
assertThat(expectedUpdatedTime).isEqualTo(updatedTime); |
|
|
assertThat(expectedUpdatedTime).isEqualTo(updatedTime); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void GameManager_Update_updatesVisualizer() { |
|
|
void GameManager_Update_updatesVisualizer() { |
|
|
// arrange |
|
|
// arrange |
|
|
|
|
|
|
|
|
GameManager gameManager = new GameManager(); |
|
|
GameManager gameManager = new GameManager(); |
|
|
gameManager.visualizer = new VisualizerPlainTextUltra(gameManager); |
|
|
gameManager.visualizer = new VisualizerPlainTextUltra(gameManager); |
|
|
VisualizerPlainTextUltra vptu = (VisualizerPlainTextUltra) gameManager.visualizer; |
|
|
VisualizerPlainTextUltra vptu = (VisualizerPlainTextUltra) gameManager.visualizer; |
|
|
|
|
|
|
|
|
// act |
|
|
// act |
|
|
|
|
|
|
|
|
String initialVptOutput = (String)vptu.GetOutput(); |
|
|
String initialVptOutput = (String)vptu.GetOutput(); |
|
|
gameManager.Update(); |
|
|
gameManager.Update(); |
|
|
String updatedVptOutput = (String)vptu.GetOutput(); |
|
|
String updatedVptOutput = (String)vptu.GetOutput(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
// assert |
|
|
assertThat(initialVptOutput).isNotEqualTo(updatedVptOutput); |
|
|
assertThat(initialVptOutput).isNotEqualTo(updatedVptOutput); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void GameManager_GostPlayerColisionTest_DetectsColosion() { |
|
|
void GameManager_GostPlayerColisionTest_DetectsColosion() { |
|
|
|
|
|
|
|
|
// arrange |
|
|
// arrange |
|
|
|
|
|
|
|
|
GameManager gameManager = new GameManager(); |
|
|
GameManager gameManager = new GameManager(); |
|
|
gameManager.player.position = gameManager.ghosts[0].position.Clone(); |
|
|
gameManager.player.position = gameManager.ghosts[0].position.Clone(); |
|
|
//act |
|
|
//act |
|
|
boolean collision = gameManager.ghostPlayerColisionTest(); |
|
|
boolean collision = gameManager.ghostPlayerColisionTest(); |
|
|
boolean expected = true; |
|
|
boolean expected = true; |
|
|
|
|
|
|
|
|
// assert |
|
|
// assert |
|
|
assertThat(collision).isEqualTo(expected); |
|
|
assertThat(collision).isEqualTo(expected); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void GameManager_GostPlayerCollisionTest_DoesntDetectColliosion() { |
|
|
void GameManager_GostPlayerCollisionTest_DoesntDetectColliosion() { |
|
|
|
|
|
|
|
|
// arrange |
|
|
// arrange |
|
|
|
|
|
|
|
|
GameManager gameManager = new GameManager(); |
|
|
GameManager gameManager = new GameManager(); |
|
|
gameManager.player.position = new Vector2(2,3); |
|
|
gameManager.player.position = new Vector2(2,3); |
|
|
gameManager.ghosts[0].position = new Vector2(4,5); |
|
|
gameManager.ghosts[0].position = new Vector2(4,5); |
|
|
//act |
|
|
//act |
|
|
boolean collision = gameManager.ghostPlayerColisionTest(); |
|
|
boolean collision = gameManager.ghostPlayerColisionTest(); |
|
|
boolean expected = false; |
|
|
boolean expected = false; |
|
|
|
|
|
|
|
|
// assert |
|
|
// assert |
|
|
assertThat(collision).isEqualTo(expected); |
|
|
assertThat(collision).isEqualTo(expected); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void GameManager_setupgame_spawnsghosts() { |
|
|
void GameManager_setupgame_spawnsghosts() { |
|
|
|
|
|
|
|
|
// arrange |
|
|
// arrange |
|
|
GameManager gameManager = new GameManager(); |
|
|
GameManager gameManager = new GameManager(); |
|
|
gameManager.map.ghostSpawns[0] = new Vector2(1, 1); |
|
|
gameManager.map.ghostSpawns[0] = new Vector2(1, 1); |
|
@ -96,6 +83,7 @@ class GameManagerTest { |
|
|
boolean expected = false; |
|
|
boolean expected = false; |
|
|
assertThat(pause).isEqualTo(expected); |
|
|
assertThat(pause).isEqualTo(expected); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void GameManager_Pause_NotPause() { |
|
|
void GameManager_Pause_NotPause() { |
|
|
GameManager gameManager = new GameManager(); |
|
|
GameManager gameManager = new GameManager(); |
|
@ -104,7 +92,7 @@ class GameManagerTest { |
|
|
boolean pause = gameManager.isPaused; |
|
|
boolean pause = gameManager.isPaused; |
|
|
boolean expected = true; |
|
|
boolean expected = true; |
|
|
assertThat(pause).isEqualTo(expected); |
|
|
assertThat(pause).isEqualTo(expected); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
@ -114,7 +102,6 @@ class GameManagerTest { |
|
|
Cell fruitSpawn = gameManager.map.getCell(gameManager.map.playerSpawn); |
|
|
Cell fruitSpawn = gameManager.map.getCell(gameManager.map.playerSpawn); |
|
|
String[] expected = {"cherry","strawberry","orange","apple","crystal"}; |
|
|
String[] expected = {"cherry","strawberry","orange","apple","crystal"}; |
|
|
//act |
|
|
//act |
|
|
|
|
|
|
|
|
gameManager.spawnFruit(); |
|
|
gameManager.spawnFruit(); |
|
|
String result = fruitSpawn.type; |
|
|
String result = fruitSpawn.type; |
|
|
//assert |
|
|
//assert |
|
|