From e7eb8367e2a1a1a17f80fbf987e0ed27d44ee823 Mon Sep 17 00:00:00 2001 From: fdai7012 Date: Thu, 8 Feb 2024 02:48:27 +0100 Subject: [PATCH] added test for player input processing3 --- 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 b9e52d7..bd075fd 100644 --- a/src/test/java/pacmanTests/PlayerTest.java +++ b/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); + } }