TowerTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    CreepyTowers.Tests.Towers TowerTests

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

public class TowerTests : TestWithMocksOrVisually

The TowerTests type exposes the following members.

Constructors

  NameDescription
Public methodTowerTests
Initializes a new instance of the TowerTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCheckForCreepUnderAttack
Public methodCreateTowerAtClickedPosition
Public methodDisplayAcidTower
Public methodDisplayAndDisposeTower
Public methodDisplayFireTower
Public methodDisplayIceTower
Public methodDisplayImpactTower
Public methodDisplaySliceTower
Public methodDisplayWaterTower
Public methodDisposingTowerRemovesTowerEntity
Public methodInitialize
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodInitializingTowerCreatesTowerModel
Public methodNotInitializingTowerDoesntCreateTowerModel
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodShowAllTowerTypesAndEffects
Public methodShowTowerFiringAtAMovingCreep
Public methodShowTowerFiringAtCreepAtRegularIntervals
Public methodShowWaterTowerWithSunlightEnabled
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, CloseAfterFirstFrame]
public void NotInitializingTowerDoesntCreateTowerModel()
{
    new Tower(TowerType.Water, Vector3D.Zero);
    Assert.AreEqual(0, EntitiesRunner.Current.GetEntitiesOfType<Model>().Count);
    Assert.AreEqual(1, EntitiesRunner.Current.GetEntitiesOfType<Tower>().Count);
}
[Test, CloseAfterFirstFrame]
public void InitializingTowerCreatesTowerModel()
{
    var tower = new Tower(TowerType.Water, Vector3D.Zero);
    tower.RenderModel();
    Assert.AreEqual(1, EntitiesRunner.Current.GetEntitiesOfType<Model>().Count);
    Assert.AreEqual(1, EntitiesRunner.Current.GetEntitiesOfType<Tower>().Count);
}
[Test]
public void DisplayWaterTower()
{
    var tower = new Tower(TowerType.Water, Vector3D.Zero, 170.0f);
    tower.RenderModel();
}
[Test]
public void DisplayAcidTower()
{
    var tower = new Tower(TowerType.Acid, Vector3D.Zero, 120.0f);
    tower.RenderModel();
}
[Test]
public void DisplayFireTower()
{
    var tower = new Tower(TowerType.Fire, Vector3D.Zero, 150.0f);
    tower.RenderModel();
}
[Test]
public void DisplayIceTower()
{
    var tower = new Tower(TowerType.Ice, Vector3D.Zero, 160.0f);
    tower.RenderModel();
}
[Test]
public void DisplayImpactTower()
{
    var tower = new Tower(TowerType.Impact, Vector3D.Zero, 120.0f);
    tower.RenderModel();
}
[Test]
public void DisplaySliceTower()
{
    var tower = new Tower(TowerType.Slice, Vector3D.Zero, 120.0f);
    tower.RenderModel();
}
[Test]
public void DisplayAndDisposeTower()
{
    var tower = new Tower(TowerType.Water, Vector3D.Zero, 170.0f);
    tower.RenderModel();
    tower.Dispose();
    Assert.AreEqual(0, EntitiesRunner.Current.GetEntitiesOfType<Tower>().Count);
}
[Test]
public void CreateTowerAtClickedPosition()
{
    var floor = new Plane(Vector3D.UnitY, 0.0f);
    new Command(pos =>
    { //ncrunch: no coverage start 
        var ray = Camera.Current.ScreenPointToRay(ScreenSpace.Current.ToPixelSpace(pos));
        var position = floor.Intersect(ray).Value;
        new Tower(TowerType.Water, position); //ncrunch: no coverage end
    }).Add(new MouseButtonTrigger(MouseButton.Left, State.Releasing));
}
[Test, CloseAfterFirstFrame]
public void DisposingTowerRemovesTowerEntity()
{
    var tower = new Tower(TowerType.Water, Vector3D.Zero);
    tower.Dispose();
    Assert.IsFalse(tower.IsActive);
}
[Test]
public void ShowTowerFiringAtCreepAtRegularIntervals()
{
    camera.ZoomLevel = 1 / 20.0f;
    var tower = new Tower(TowerType.Water, new Vector2D(0, 0));
    var creep = new Creep(CreepType.Cloth, new Vector2D(2, 0));
    tower.RenderModel();
    creep.RenderModel();
    new TowerTargetFinder();
}
[Test, CloseAfterFirstFrame]
public void CheckForCreepUnderAttack()
{
    var tower = new Tower(TowerType.Slice, new Vector2D(0, 0));
    tower.RenderModel();
    var creep = new Creep(CreepType.Cloth, new Vector2D(1, 0));
    new TowerTargetFinder();
    AdvanceTimeAndUpdateEntities(2.1f);
    Assert.Less(creep.GetStatPercentage("Hp"), 1);
}
[Test]
public void ShowTowerFiringAtAMovingCreep()
{
    camera.ZoomLevel = 1 / 20.0f;
    var tower = new Tower(TowerType.Water, new Vector2D(0, 0));
    var creep = new Creep(CreepType.Cloth, new Vector2D(1, 3));
    creep.Path = new List<Vector2D> { (new Vector2D(1, -10)) };
    tower.RenderModel();
    creep.RenderModel();
    new TowerTargetFinder();
}
[Test]
public void ShowAllTowerTypesAndEffects()
{
    var tower = new Tower(TowerType.Acid, Vector3D.Zero);
    tower.RenderModel();
    var creep = new Creep(CreepType.Cloth, new Vector2D(2, 8));
    new Command(() => { tower.FireAtCreep(creep); }).Add(new KeyTrigger(Key.Space));
    new Command(() => { tower.RotationZ += 2; }).Add(new KeyTrigger(Key.A, State.Pressed));
    new Command(() => { tower.RotationZ -= 2; }).Add(new KeyTrigger(Key.D, State.Pressed));
    new Command(() =>
    { //ncrunch: no coverage start
        tower.Dispose();
        tower = new Tower(CycleTypeUpwards(tower.Type), Vector3D.Zero);
        tower.RenderModel(); //ncrunch: no coverage end
    }).Add(new KeyTrigger(Key.W));
    new Command(() =>
    { //ncrunch: no coverage start
        tower.Dispose();
        tower = new Tower(CycleTypeDownwards(tower.Type), Vector3D.Zero);
        tower.RenderModel(); //ncrunch: no coverage end
    }).Add(new KeyTrigger(Key.S));
}
[Test]
public void ShowWaterTowerWithSunlightEnabled()
{
    new Player();
    Camera.Current.Position = new Vector3D(0.0f, -4.0f, 2.0f);
    var tower = new Tower(TowerType.Water, Vector3D.Zero);
    tower.RenderModel();
}
See Also