|
@ -0,0 +1,51 @@ |
|
|
|
|
|
package pacmanTests; |
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
|
|
import pacmanGame.GameManager; |
|
|
|
|
|
import pacmanGame.Map; |
|
|
|
|
|
import pacmanGame.VisualizerPlainText; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GameManagerTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void GameManager_Update_increasesTime() { |
|
|
|
|
|
// arrange |
|
|
|
|
|
|
|
|
|
|
|
GameManager gameManager = new GameManager(); |
|
|
|
|
|
VisualizerPlainText vpt = new VisualizerPlainText(gameManager); |
|
|
|
|
|
|
|
|
|
|
|
// act |
|
|
|
|
|
|
|
|
|
|
|
int initialTime = gameManager.time; |
|
|
|
|
|
gameManager.Update(); |
|
|
|
|
|
int updatedTime = gameManager.time; |
|
|
|
|
|
|
|
|
|
|
|
int expectedUpdatedTime = initialTime + 1; |
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
|
|
|
assertThat(expectedUpdatedTime).isEqualTo(updatedTime); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void GameManager_Update_updatesVisualizer() { |
|
|
|
|
|
// arrange |
|
|
|
|
|
|
|
|
|
|
|
GameManager gameManager = new GameManager(); |
|
|
|
|
|
VisualizerPlainText vpt = (VisualizerPlainText) gameManager.visualizer; |
|
|
|
|
|
|
|
|
|
|
|
// act |
|
|
|
|
|
|
|
|
|
|
|
String initialVptOutput = (String)vpt.GetOutput(); |
|
|
|
|
|
gameManager.Update(); |
|
|
|
|
|
String updatedVptOutput = (String)vpt.GetOutput(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
|
|
|
assertThat(initialVptOutput).isNotEqualTo(updatedVptOutput); |
|
|
|
|
|
} |
|
|
|
|
|
} |