|
|
@ -62,4 +62,27 @@ class PlayerTest { |
|
|
|
// assert |
|
|
|
assertThat(direction).isEqualTo(expectedDdirection); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void Player_processInput_changesDirectionDown() { |
|
|
|
// 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(0,-1); |
|
|
|
// act |
|
|
|
player.processInput('s'); |
|
|
|
Vector2 direction = player.direction; |
|
|
|
// assert |
|
|
|
assertThat(direction).isEqualTo(expectedDdirection); |
|
|
|
} |
|
|
|
} |