From ee6e0964e94c583c642db18b2a4cfaca29c45da4 Mon Sep 17 00:00:00 2001 From: fdai7012 Date: Thu, 8 Feb 2024 17:53:34 +0100 Subject: [PATCH] added test for chase behavior --- src/test/java/pacmanTests/GhostTest.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/test/java/pacmanTests/GhostTest.java b/src/test/java/pacmanTests/GhostTest.java index 1c60e93..34df89b 100644 --- a/src/test/java/pacmanTests/GhostTest.java +++ b/src/test/java/pacmanTests/GhostTest.java @@ -53,4 +53,27 @@ class GhostTest { // assert //assertThat(position).isEqualTo(expectedPosition); } + + @Test + void Ghost_chase_chasesPlayer() { + // arrange + String[] mapTest = { + "wwwww", + "w...w", + "wwwww" + }; + GameManager gameManager = new GameManager(); + gameManager.map = new Map(mapTest, gameManager); + + Vector2 expectedGhostPos = new Vector2(2, 1); + gameManager.player.position = new Vector2(1, 1); + gameManager.ghosts[0].position = new Vector2(3, 1); + // act + + gameManager.ghosts[0].move(); + Vector2 ghostPos = gameManager.ghosts[0].position; + + // assert + assertThat(ghostPos).isEqualTo(expectedGhostPos); + } } \ No newline at end of file