Skip to content

Commit

Permalink
Added further tests into the wave test classes. Some helper methods h…
Browse files Browse the repository at this point in the history
…ave been added to wave related classes.
  • Loading branch information
BlairCannon97 committed Sep 30, 2023
1 parent 1dd91e6 commit 24e36dd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,21 @@ public void setWaveIndex(int index) {
public int getNumWaves() {
return this.numWaves;
}

/**
* Get the current mob index
* @return mob index
*/
public int getMobIndex() {
return this.mobIndex;
}

/**
* Get the current wave index
* @return wave index
*/
public int getWaveIndex() {
return this.waveIndex;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class WaveTask extends DefaultTask implements PriorityTask {
"sounds/waves/wave-end/Wave_Over_01.ogg"
};

private Sound waveStart;
private Sound waveEnd;
private final Sound waveStart;
private final Sound waveEnd;

/**
* Constructor for the WaveTask
Expand Down Expand Up @@ -71,7 +71,7 @@ public int getPriority() {

/**
* Starts the WaveTask and initialises all relevant attributes.
* Sets the current count of enmies to be the size of the current wave.
* Sets the current count of enemies to be the size of the current wave.
*/
@Override
public void start() {
Expand Down Expand Up @@ -121,4 +121,12 @@ public void update() {
}
}
}
}

/**
* Checks if the current wave is in progress
* @return true if the wave is in progress, false otherwise
*/
public boolean isWaveInProgress() {
return waveInProgress;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
package com.csse3200.game.components.tasks.waves;

import com.csse3200.game.areas.ForestGameArea;
import com.csse3200.game.entities.factories.WaveFactory;
import com.csse3200.game.extensions.GameExtension;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ServiceLocator;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@ExtendWith(GameExtension.class)
@ExtendWith(MockitoExtension.class)
class LevelWavesTest {

LevelWaves levelWaves;
WaveClass wave;
ServiceLocator serviceLocator;

@BeforeEach
void setUp() {
levelWaves = (LevelWaves) WaveFactory.createWaves();
wave = mock(WaveClass.class);
}

@Test
public void testAddWave() {
levelWaves.addWave(wave);
assertEquals(3, levelWaves.waves.size());
}

@Test
public void testSpawnWaveStart() {

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.csse3200.game.components.tasks.waves;

import com.badlogic.gdx.audio.Sound;
import com.csse3200.game.areas.ForestGameArea;
import com.csse3200.game.areas.terrain.TerrainFactory;
import com.csse3200.game.components.tasks.DroidCombatTask;
import com.csse3200.game.extensions.GameExtension;
import com.csse3200.game.services.GameTime;
Expand All @@ -14,6 +16,7 @@
import java.util.logging.Level;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -24,6 +27,7 @@ class WaveTaskTest {
WaveTask waveTask;
ResourceService resourceService;
LevelWaves level;
ForestGameArea gameArea;
@BeforeEach
void setUp() {
resourceService = ServiceLocator.getResourceService();
Expand All @@ -48,9 +52,9 @@ public void testGetPriority() {

@Test
public void testStartWave() {
WaveTask waveTask = new WaveTask();
waveTask.start();
assertEquals(1, waveTask.getPriority());
assertTrue(waveTask.isWaveInProgress());
}

}

0 comments on commit 24e36dd

Please sign in to comment.