From 65263ff3943854a3eede133fb4a661514c293b7d Mon Sep 17 00:00:00 2001 From: fdai7012 Date: Thu, 8 Feb 2024 02:48:59 +0100 Subject: [PATCH] added test for player input processing4 --- src/test/java/pacmanTests/PlayerTest.java | 25 ++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/test/java/pacmanTests/PlayerTest.java b/src/test/java/pacmanTests/PlayerTest.java index bd075fd..3cd3d87 100644 --- a/src/test/java/pacmanTests/PlayerTest.java +++ b/src/test/java/pacmanTests/PlayerTest.java @@ -85,7 +85,7 @@ class PlayerTest { // assert assertThat(direction).isEqualTo(expectedDdirection); } - + @Test void Player_processInput_changesDirectionLeft() { // arrange @@ -108,4 +108,27 @@ class PlayerTest { // assert assertThat(direction).isEqualTo(expectedDdirection); } + + @Test + void Player_processInput_changesDirectionRight() { + // 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('d'); + Vector2 direction = player.direction; + // assert + assertThat(direction).isEqualTo(expectedDdirection); + } }