-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.csse3200.game.components.tasks; | ||
|
||
import com.csse3200.game.ai.tasks.AITaskComponent; | ||
import com.csse3200.game.entities.Entity; | ||
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 org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.mockito.Mockito.*; | ||
|
||
@ExtendWith(GameExtension.class) | ||
@ExtendWith(MockitoExtension.class) | ||
class SpawnWaveTaskTest { | ||
|
||
@Test | ||
void shouldTriggerSpawning() { | ||
GameTime time = mock(GameTime.class); | ||
when(time.getTime()).thenReturn(11000L); | ||
ServiceLocator.registerTimeSource(time); | ||
SpawnWaveTask waveTask = new SpawnWaveTask(); | ||
|
||
AITaskComponent aiTaskComponent = new AITaskComponent().addTask(waveTask); | ||
Entity entity = new Entity().addComponent(aiTaskComponent).addComponent(new PhysicsMovementComponent()); | ||
entity.create(); | ||
|
||
// Register callbacks | ||
EventListener0 callback = mock(EventListener0.class); | ||
entity.getEvents().addListener("spawnWave", callback); | ||
|
||
waveTask.update(); | ||
|
||
verify(callback).handle(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters