public void ShotOnTwoInvadersInTowerRangeHitsOnlyOneInvader() { // Given TestTower with Hit Shot SetUpTowerLocationWithRandomDoubleValue(0.0); // Given two Invaders that are in range of TestTower // 5 // 4 // 3 // 2 // 1 t // 0 i i // 0 1 2 3 4 5 // With default invader health Path firstInvaderPath = new Path( new[] { new MapLocation(x: 1, y: 0, map: TestMap), } ); Invader firstInvaderInTowerRange = new Invader( path: firstInvaderPath, pathStep: 0, health: Invader.DefaultHealth ); Path secondInvaderPath = new Path( new[] { new MapLocation(x: 1, y: 0, map: TestMap), } ); Invader secondInvaderInTowerRange = new Invader( path: secondInvaderPath, pathStep: 0, health: Invader.DefaultHealth ); Assert.IsTrue(TestTower.IsInRangeOf(firstInvaderInTowerRange)); Assert.IsTrue(TestTower.IsInRangeOf(secondInvaderInTowerRange)); // When Tower fires on two invaders TestTower.FireOnInvaders( new List <Invader> { firstInvaderInTowerRange, secondInvaderInTowerRange } ); Assert.IsFalse( firstInvaderInTowerRange.IsHit && secondInvaderInTowerRange.IsHit, "Then only one invader should be hit" ); }
/// <summary> /// Sets up the <c>TestInvader</c> that is in <c>TestTower.Range</c> /// with <c>Invader.DefaultHealth</c> and 0 as <c>pathStep</c> /// Here is how <c>invaderPath</c> looks like /// 5 /// 4 /// 3 /// 2 /// 1 t /// 0 i i i i i i /// 0 1 2 3 4 5 /// </summary> /// <param name="health">TestInvader's health</param> private void SetUpTestInvaderInTowerRangeWithHealth(int health) { Path invaderPath = new Path( new [] { new MapLocation(x: 0, y: 0, map: TestMap), new MapLocation(x: 1, y: 0, map: TestMap), new MapLocation(x: 2, y: 0, map: TestMap), new MapLocation(x: 3, y: 0, map: TestMap), new MapLocation(x: 4, y: 0, map: TestMap), new MapLocation(x: 5, y: 0, map: TestMap), } ); TestInvaderInTowerRange = new Invader( path: invaderPath, pathStep: 0, health: health ); }