From 6cbbcb8ac7669f4e80748581dfd6e1ec5dc70961 Mon Sep 17 00:00:00 2001 From: fdai7012 Date: Thu, 8 Feb 2024 02:46:11 +0100 Subject: [PATCH] added test for player input processing --- src/test/java/pacmanTests/PlayerTest.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/test/java/pacmanTests/PlayerTest.java b/src/test/java/pacmanTests/PlayerTest.java index 3a6c8f9..c8de5ff 100644 --- a/src/test/java/pacmanTests/PlayerTest.java +++ b/src/test/java/pacmanTests/PlayerTest.java @@ -39,4 +39,27 @@ class PlayerTest { // assert assertThat(position).isEqualTo(expectedPosition); } + + @Test + void Player_processInput_changesDirectionUp() { + // 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('w'); + Vector2 direction = player.direction; + // assert + assertThat(direction).isEqualTo(expectedDdirection); + } }