public void ResolveBattle_BattleshipHitOnce_ReplacedWithDamagedBattleship() { _hitGenerator.GenerateHits(Arg.Any<Dictionary<CombatUnitType, int>>(), Arg.Any<Func<CombatUnitType, int>>()) .Returns(1); _attackers = new Dictionary<CombatUnitType, int>() { { TestUtils.CreateBattleshipType(), 1 } }; _defenders = new Dictionary<CombatUnitType, int>() { { TestUtils.CreateFighterType(), 1 } }; _battle = new Battle(_attackers, _defenders, _attackerCasualtyOrder, _defenderCasualtyOrder, _hitGenerator); _battle.ResolveBattle(); Assert.AreEqual(1, _battle.SurvivingAttackers.Count); Assert.AreEqual(ValidCombatUnitTypes.DamagedBattleship, _battle.SurvivingAttackers.First().Key.Type); }
private Battle ResolveBattleForCurrentUnits() { var attackerCasualtyOrder = _attackerCasualtyOrderViewModel.CasualtyOrder.Select(u => u.ToCombatUnitType().Type).ToList(); var defenderCasualtyOrder = _defenderCasualtyOrderViewModel.CasualtyOrder.Select(u => u.ToCombatUnitType().Type).ToList(); var battle = new Battle(_currentAttackers, _currentDefenders, attackerCasualtyOrder, defenderCasualtyOrder, _hitGenerator); battle.ResolveBattle(); return battle; }
public void ResolveBattle_OneOf2BattleshipsTakesHit_OneBattleshipAndOneDamagedBattleshipRemain() { _hitGenerator.GenerateHits(Arg.Any<Dictionary<CombatUnitType, int>>(), Arg.Any<Func<CombatUnitType, int>>()) .Returns(1); _attackers = new Dictionary<CombatUnitType, int>() { { TestUtils.CreateBattleshipType(), 2 } }; _defenders = new Dictionary<CombatUnitType, int>() { { TestUtils.CreateFighterType(), 1 } }; _battle = new Battle(_attackers, _defenders, _attackerCasualtyOrder, _defenderCasualtyOrder, _hitGenerator); _battle.ResolveBattle(); Assert.AreEqual(2, _battle.SurvivingAttackers.Count); Assert.AreEqual(2, _battle.SurvivingAttackers.Values.Sum()); Assert.AreEqual(1, _battle.SurvivingAttackers.Count(a => a.Key.Type == ValidCombatUnitTypes.Battleship)); Assert.AreEqual(1, _battle.SurvivingAttackers.Count(a => a.Key.Type == ValidCombatUnitTypes.DamagedBattleship)); }