|
|
@ -0,0 +1,42 @@ |
|
|
|
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.*; |
|
|
|
|
|
|
|
|
|
|
|
class PlayerTest { |
|
|
|
|
|
|
|
@Test |
|
|
|
void Player_moving_changesPosition() { |
|
|
|
// arrange |
|
|
|
GameManager gameManager = new GameManager(); |
|
|
|
Player player = gameManager.player; |
|
|
|
player.position = new Vector2(2,2); |
|
|
|
player.direction = new Vector2(1,0); |
|
|
|
Vector2 expectedPosition = new Vector2(3,2); |
|
|
|
// act |
|
|
|
player.Move(); |
|
|
|
Vector2 position = player.position; |
|
|
|
// assert |
|
|
|
assertThat(position).isEqualTo(expectedPosition); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void Player_wall_obstructsMovement() { |
|
|
|
// arrange |
|
|
|
GameManager gameManager = new GameManager(); |
|
|
|
Player player = gameManager.player; |
|
|
|
player.position = new Vector2(2,2); |
|
|
|
player.direction = new Vector2(-1,0); |
|
|
|
Vector2 expectedPosition = new Vector2(2,2); |
|
|
|
// act |
|
|
|
player.Move(); |
|
|
|
Vector2 position = player.position; |
|
|
|
// assert |
|
|
|
assertThat(position).isEqualTo(expectedPosition); |
|
|
|
} |
|
|
|
} |