WaveGeneratorTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    CreepyTowers.Tests TestWithCreepyTowersMockContentLoaderOrVisually
      CreepyTowers.Tests CreepyTowersGameForTests
        CreepyTowers.Tests.Creeps WaveGeneratorTests

Namespace: CreepyTowers.Tests.Creeps
Assembly: CreepyTowers.Tests (in CreepyTowers.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class WaveGeneratorTests : CreepyTowersGameForTests

The WaveGeneratorTests type exposes the following members.

Constructors

  NameDescription
Public methodWaveGeneratorTests
Initializes a new instance of the WaveGeneratorTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCreepIsSpawnedAtTheSpawnPoint
Public methodCreepSpawnedInWaveOnlyAfterSpawnInterval
Public methodDispose (Inherited from CreepyTowersGameForTests.)
Public methodFirstItemInWaveListHasWaveWaitTimeAddedToItsSpawnInterval
Public methodIfNoWaveDataThenNoWavesSpawned
Public methodInitialize (Overrides CreepyTowersGameForTests Initialize .)
Public methodInitializeCreepyTowersMockContentLoader (Inherited from TestWithCreepyTowersMockContentLoaderOrVisually.)
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodNextCreepIsSpawnedOnlyAfterCreepSpawnTimeInterval
Public methodNextWaveIsSpawnedOnlyAfterElapsedTimeIsOver
Public methodNoCreepsSpawnedIfCreepListIsEmpty
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodSpawnCreepWaves
Public methodTestTheTotalOfNumberOfCreepsInLevel
Public methodWaveCreateOnlyAfterWaitTime
Top
Fields

  NameDescription
Protected fieldgame (Inherited from CreepyTowersGameForTests.)
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, CloseAfterFirstFrame]
public void SpawnCreepWaves()
{
    new WaveGenerator(waveList, Vector3D.One);
}
[Test, CloseAfterFirstFrame]
public void CreepIsSpawnedAtTheSpawnPoint()
{
    var creepPos = new Vector3D(2.0f, 3.0f, 1.0f);
    new WaveGenerator(waveList, creepPos);
    AdvanceTimeAndUpdateEntities(1.1f);
    Assert.AreEqual(creepPos, EntitiesRunner.Current.GetEntitiesOfType<Creep>()[0].Position);
}
[Test, CloseAfterFirstFrame]
public void IfNoWaveDataThenNoWavesSpawned()
{
    var waves = new List<CreepWave>();
    new WaveGenerator(waves, Vector3D.One);
    Assert.AreEqual(0, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
}
[Test, CloseAfterFirstFrame]
public void WaveCreateOnlyAfterWaitTime()
{
    new WaveGenerator(waveList, Vector3D.One);
    Assert.AreEqual(0, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
    AdvanceTimeAndUpdateEntities(1.0f);
    Assert.AreEqual(1, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
}
[Test, CloseAfterFirstFrame]
public void CreepSpawnedInWaveOnlyAfterSpawnInterval()
{
    new WaveGenerator(waveList, Vector3D.One);
    Assert.AreEqual(0, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
    AdvanceTimeAndUpdateEntities(1.1f);
    Assert.GreaterOrEqual(EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count, 1);
    AdvanceTimeAndUpdateEntities(1.1f);
    Assert.GreaterOrEqual(EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count, 2);
}
[Test, CloseAfterFirstFrame]
public void NoCreepsSpawnedIfCreepListIsEmpty()
{
    var waveA = new CreepWave(0.0f, 1.0f);
    var waves = new List<CreepWave> { waveA };
    new WaveGenerator(waves, Vector3D.One);
    Assert.AreEqual(0, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
}
[Test, CloseAfterFirstFrame]
public void FirstItemInWaveListHasWaveWaitTimeAddedToItsSpawnInterval()
{
    var waveA = new CreepWave(0.05f, 0.05f, "Paper, Squad, Paper", "CreepWave");
    waveList = new List<CreepWave> { waveA };
    new WaveGenerator(waveList, Vector3D.One);
    AdvanceTimeAndUpdateEntities(5.0f);
    Assert.AreEqual(2, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
}
[Test, CloseAfterFirstFrame]
public void NextWaveIsSpawnedOnlyAfterElapsedTimeIsOver()
{
    var waveA = new CreepWave(0.1f, 0.1f, "Paper, Paper", "PaperWave");
    var waveB = new CreepWave(0.3f, 0.1f, "Wood", "WoodWave");
    new WaveGenerator(new List<CreepWave> { waveA, waveB }, Vector3D.One);
    AdvanceTimeAndUpdateEntities(0.1f);
    Assert.AreEqual(1, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
    AdvanceTimeAndUpdateEntities(0.1f);
    Assert.AreEqual(2, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
    AdvanceTimeAndUpdateEntities(0.4f);
    Assert.AreEqual(3, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
}
[Test, CloseAfterFirstFrame]
public void TestTheTotalOfNumberOfCreepsInLevel()
{
    var waveA = new CreepWave(1.0f, 1.0f, "Paper, Paper", "PaperWave");
    var generator = new WaveGenerator(new List<CreepWave> { waveA }, Vector3D.One);
    AdvanceTimeAndUpdateEntities(1.01f);
    AdvanceTimeAndUpdateEntities(0.1f);
    Assert.AreEqual(2, generator.TotalCreepsInLevel);
}
[Test, CloseAfterFirstFrame, Ignore]
public void NextCreepIsSpawnedOnlyAfterCreepSpawnTimeInterval()
{
    if (!IsMockResolver)
        return;
    var waveA = new CreepWave(1.0f, 1.0f, "Paper, Paper", "PaperWave");
    new WaveGenerator(new List<CreepWave> { waveA }, Vector3D.One);
    AdvanceTimeAndUpdateEntities(1.01f);
    Assert.AreEqual(1, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
    AdvanceTimeAndUpdateEntities(0.1f);
    Assert.AreEqual(1, EntitiesRunner.Current.GetEntitiesOfType<Creep>().Count);
}
See Also