Browse Source

added test for player input processing3

main
fdai7012 11 months ago
parent
commit
e7eb8367e2
  1. 23
      src/test/java/pacmanTests/PlayerTest.java

23
src/test/java/pacmanTests/PlayerTest.java

@ -85,4 +85,27 @@ class PlayerTest {
// assert
assertThat(direction).isEqualTo(expectedDdirection);
}
@Test
void Player_processInput_changesDirectionLeft() {
// arrange
String[] mapTest = {
"...",
"...",
"..."
};
GameManager gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager);
Player player = gameManager.player;
player.position = new Vector2(1,1);
player.direction = new Vector2(-1,0);
Vector2 expectedDdirection = new Vector2(-1,0);
// act
player.processInput('a');
Vector2 direction = player.direction;
// assert
assertThat(direction).isEqualTo(expectedDdirection);
}
}
Loading…
Cancel
Save