From 2de3b39ad6c286362ee81fdad0cb342f81d6208a Mon Sep 17 00:00:00 2001 From: fdai7012 Date: Thu, 8 Feb 2024 18:06:29 +0100 Subject: [PATCH] added another test for chase behavior --- src/test/java/pacmanTests/GhostTest.java | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/java/pacmanTests/GhostTest.java b/src/test/java/pacmanTests/GhostTest.java index 2b995ab..3a2708d 100644 --- a/src/test/java/pacmanTests/GhostTest.java +++ b/src/test/java/pacmanTests/GhostTest.java @@ -77,4 +77,32 @@ class GhostTest { assertThat(ghostPos).isEqualTo(expectedGhostPos); } + @Test + void Ghost_chase_chasesPlayer2() { + // arrange + String[] mapTest = { + "wwwwwwwwwwwwwwwwwwwwwwwwwwww", + "w..........................w", + "wwwwwwwwwwwwwwwwwwwwwwwwwwww" + }; + GameManager gameManager = new GameManager(); + gameManager.map = new Map(mapTest, gameManager); + + Vector2 expectedGhostPos = new Vector2(19, 1); + gameManager.player.position = new Vector2(1, 1); + gameManager.ghosts[0].position = new Vector2(25, 1); + // act + + gameManager.ghosts[0].move(); + gameManager.ghosts[0].move(); + gameManager.ghosts[0].move(); + gameManager.ghosts[0].move(); + gameManager.ghosts[0].move(); + gameManager.ghosts[0].move(); + Vector2 ghostPos = gameManager.ghosts[0].position; + + // assert + assertThat(ghostPos).isEqualTo(expectedGhostPos); + } + } \ No newline at end of file