From 69ca995b8f49aff6418abb63cfbcc474f9961e39 Mon Sep 17 00:00:00 2001 From: meganroxburgh <128758122+meganroxburgh@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:51:27 +1000 Subject: [PATCH] Created MobAttackTaskTest, needs to be edited further --- .../components/tasks/MobAttackTaskTest.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java index 1e45d2c0a..95cd0fffc 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java @@ -8,9 +8,9 @@ import com.csse3200.game.events.listeners.EventListener0; import com.csse3200.game.extensions.GameExtension; import com.csse3200.game.utils.math.Vector2Utils; -import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; +import com.csse3200.game.physics.components.PhysicsMovementComponent; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -20,25 +20,30 @@ @ExtendWith(GameExtension.class) @ExtendWith(MockitoExtension.class) class MobAttackTaskTest { - @Mock + /** + * Class for testing MobAttackTask + */ GameTime gameTime; -// @BeforeEach -// void beforeEach() { -// ServiceLocator.registerTimeSource(gameTime); -// // To Do -// } -// -// @Test -// void shouldShootProjectile() { -// Entity target = new Entity(); -// target.setPosition(2f, 2f); + @BeforeEach + void setUp() { + ServiceLocator.registerTimeSource(gameTime); + } + + @Test + void shouldShootProjectile() { +// MobAttackTask mobAttackTask = new MobAttackTask(2, 40); // -// AITaskComponent ai = new AITaskComponent().addTask(new MobAttackTask(target, 10, 5, 10)); -// Entity entity = makePhysicsEntity().addComponent(ai); +// AITaskComponent aiTaskComponent = new AITaskComponent().addTask(mobAttackTask); +// Entity entity = new Entity().addComponent(aiTaskComponent); // entity.create(); -// entity.setPosition(0f, 0f); // -// // To Do -// } +// // Register callbacks +// EventListener0 callback = mock(EventListener0.class); +// entity.getEvents().addListener("shootStart", callback); +// +// mobAttackTask.start(); +// +// verify(callback).handle(); + } }