Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
CreepyTowers.Tests TestWithCreepyTowersMockContentLoaderOrVisually
CreepyTowers.Tests CreepyTowersGameForTests
CreepyTowers.Tests TowerTargetFinderTests
Namespace: CreepyTowers.Tests
Assembly: CreepyTowers.Tests (in CreepyTowers.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The TowerTargetFinderTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
TowerTargetFinderTests | Initializes a new instance of the TowerTargetFinderTests class |
Methods
Fields
Name | Description | |
---|---|---|
game | (Inherited from CreepyTowersGameForTests.) |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test, CloseAfterFirstFrame] public void InAbsenceOfCreepsTheTowerDoesNotFire() { var tower = new Tower(TowerType.Fire, Vector2D.Zero); AdvanceTimeTillTowerAttacks(tower); Assert.IsFalse(tower.IsOnCooldown); }
[Test, CloseAfterFirstFrame] public void TowerDoesNotAttackIfStillInCooldown() { var tower = new Tower(TowerType.Water, Vector2D.Zero); var creep = CreateCreepOfType(CreepType.Cloth, 2.0f * Vector3D.UnitY); tower.RenderModel(); AdvanceToJustBeforeTowerAttack(tower); Assert.IsTrue(tower.IsOnCooldown); Assert.AreEqual(1, creep.GetStatPercentage("Hp")); }
[Test, CloseAfterFirstFrame] public void InactiveTowerDoesNotFire() { var tower = new Tower(TowerType.Water, Vector2D.Zero); var creep = CreateCreepOfType(CreepType.Cloth, Vector3D.UnitY); tower.IsActive = false; AdvanceTimeTillTowerAttacks(tower); Assert.AreEqual(1, creep.GetStatPercentage("Hp")); }
[Test, CloseAfterFirstFrame] public void TowerDoesNotAttackInactiveCreep() { var tower = new Tower(TowerType.Water, Vector2D.Zero); var creep = CreateCreepOfType(CreepType.Cloth, Vector3D.UnitY); creep.IsActive = false; AdvanceTimeTillTowerAttacks(tower); Assert.AreEqual(1, creep.GetStatPercentage("Hp")); }
[Test, CloseAfterFirstFrame] public void DirectShotTowerFiresAtNearestCreep() { var tower = new Tower(TowerType.Water, Vector2D.Zero); var creep = CreateCreepOfType(CreepType.Cloth, Vector3D.UnitY); tower.RenderModel(); var furtherCreep = CreateCreepOfType(CreepType.Cloth, new Vector2D(2.75f, 2.75f)); AdvanceTimeTillTowerAttacks(tower); AdvanceTimeAndUpdateEntities(1.0f); Assert.IsTrue(tower.IsOnCooldown); Assert.LessOrEqual(0, EntitiesRunner.Current.GetEntitiesOfType<ParticleEmitter>().Count); Assert.Less(creep.GetStatPercentage("Hp"), 1); Assert.AreEqual(1, furtherCreep.GetStatPercentage("Hp")); }
[Test, CloseAfterFirstFrame] public void RadiusAttackExcludesCreepsOutsideRange() { var tower = new Tower(TowerType.Slice, Vector3D.Zero); tower.RenderModel(); var creep = CreateCreepOfType(CreepType.Cloth, Vector3D.UnitY); Assert.AreEqual(AttackType.Cone, tower.AttackType); var farCreep = CreateCreepOfType(CreepType.Cloth, new Vector3D(100, 100, 0)); AdvanceTimeTillTowerAttacks(tower); Assert.IsTrue(tower.IsOnCooldown); Assert.Less(creep.GetStatPercentage("Hp"), 1); Assert.AreEqual(1, farCreep.GetStatPercentage("Hp")); }
[Test, CloseAfterFirstFrame] public void RadiusAttackIncludesCreepsWithinRange() { var tower = new Tower(TowerType.Fire, Vector3D.Zero); var creep = CreateCreepOfType(CreepType.Cloth, Vector3D.UnitY); var nearCreep = new Creep(CreepType.Cloth, new Vector2D(0.0f, 2.0f)); AdvanceTimeTillTowerAttacks(tower); Assert.AreEqual(AttackType.Circle, tower.AttackType); Assert.IsTrue(tower.IsOnCooldown); Assert.Less(creep.GetStatPercentage("Hp"), 1); Assert.Less(nearCreep.GetStatPercentage("Hp"), 1); }
[Test, CloseAfterFirstFrame] public void ConeAttackExcludesCreepsOutsideAngle() { var tower = new Tower(TowerType.Slice, Vector3D.Zero); tower.RenderModel(); var creep = CreateCreepOfType(CreepType.Cloth, Vector3D.UnitY); var outsideCreep = CreateCreepOfType(CreepType.Cloth, new Vector2D(2.75f, 1.0f)); AdvanceTimeTillTowerAttacks(tower); Assert.AreEqual(AttackType.Cone, tower.AttackType); Assert.IsTrue(tower.IsOnCooldown); Assert.Less(creep.GetStatPercentage("Hp"), 1); Assert.AreEqual(1, outsideCreep.GetStatPercentage("Hp")); }
[Test, CloseAfterFirstFrame] public void ConeAttackIncludesCreepsWithinAngle() { var tower = new Tower(TowerType.Slice, Vector3D.Zero); tower.RenderModel(); var creep = CreateCreepOfType(CreepType.Cloth, Vector3D.UnitY); var insideCreep = CreateCreepOfType(CreepType.Cloth, new Vector2D(0.0f, 1.5f)); AdvanceTimeTillTowerAttacks(tower); Assert.AreEqual(AttackType.Cone, tower.AttackType); Assert.IsTrue(tower.IsOnCooldown); Assert.Less(creep.GetStatPercentage("Hp"), 1); Assert.Less(insideCreep.GetStatPercentage("Hp"), 1); }
[Test] public void SuccessfulAttackProducesHitEffect() { var tower = new Tower(TowerType.Fire, new Vector3D(2, 2, 0)); CreateCreepOfType(CreepType.Cloth, Vector3D.UnitY); AdvanceTimeTillTowerAttacks(tower); }
See Also