public void GivenIHaveEnteredFleetsIntoTheBattleField(int numberOfFleets) { for (int i = 0; i < numberOfFleets; i++) { battleField.Fleets.Add(FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst)); } }
public void CreateFleetConfigurationOverSizedTest() { IFleet fleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); var size = fleet.StarShips.Sum(x => x.Size); Assert.True(size < 12000); }
public void GetTargetShipTest() { IFleet fleet = FleetFactory.CreateFleet(FleetConfigurationType.HeavyShips, BattleStratageyType.NoPriority); IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser); var ship = attackImplement.GetTargetShip(null, fleet); Assert.NotNull(ship); }
public void GetWeekTargetShipTest() { IFleet fleet = FleetFactory.CreateFleet(FleetConfigurationType.SmallShips, BattleStratageyType.WeekShipsFirst); IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser); var ship = attackImplement.GetTargetShip(BattleStratageyType.WeekShipsFirst, fleet); Assert.NotNull(ship); }
public void EnterFieldTest() { IBattleField battleField = BattleFieldFactory.CreateBattleField(BattleFieldType.Small); IFleet myfleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); myfleet.EnterField(battleField); Assert.True(battleField.Fleets.Count() > 0); }
public void AdvanceRoundTest() { IBattleField battleField = BattleFieldFactory.CreateBattleField(BattleFieldType.Small); IFleet fleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); fleet.EnterField(battleField); battleField.AdvanceRound(fleet); Assert.True(fleet.NumberOfRoundsCompleted == 1); }
public void PlasmaCannonAmmoUnAvailableTest() { IAttackImplement ai = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon); IFleet fleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); var shots = ai.Ammo; for (int i = 0; i < shots; i++) { ai.Fire(fleet, BattleStratageyType.StrongShipsFirst); } Assert.False(ai.AmmoAvailable); }
public void AttackEnemyShipsTest() { IFleet myfleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); IFleet enemyfleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); var oTotalHealthAndArmor = enemyfleet.StarShips.Sum(x => x.Health) + enemyfleet.StarShips.Sum(x => x.Armor); myfleet.AttacKEnemyShips(enemyfleet); var newTotalHealthAndArmor = enemyfleet.StarShips.Sum(x => x.Health) + enemyfleet.StarShips.Sum(x => x.Armor); var shipsDestroyed = enemyfleet.StarShips.Where(x => x.Health == 0).ToList(); Assert.True(oTotalHealthAndArmor > newTotalHealthAndArmor); }
public void LaserAmmoNeverUnAvailableTest() { IAttackImplement ai = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser); IFleet fleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); for (int i = 0; i < 600; i++) { ai.Fire(fleet, BattleStratageyType.StrongShipsFirst); } Assert.True(ai.AmmoAvailable); Assert.False(ai.Ammo.HasValue); }
public void FireTest() { IFleet fleet = FleetFactory.CreateFleet(FleetConfigurationType.HeavyShips, BattleStratageyType.NoPriority); var oTotalHealthAndArmor = fleet.StarShips.Sum(x => x.Health) + fleet.StarShips.Sum(x => x.Armor); IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser); //Has A random miss rate for (int i = 0; i < 1000; i++) { attackImplement.Fire(fleet, BattleStratageyType.WeekShipsFirst); } var newTotalHealthAndArmor = fleet.StarShips.Sum(x => x.Health) + fleet.StarShips.Sum(x => x.Armor); Assert.True(oTotalHealthAndArmor > newTotalHealthAndArmor); }
public void StartRoundTest() { IBattleField battleField = BattleFieldFactory.CreateBattleField(BattleFieldType.Small); IFleet fleet1 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); IFleet fleet2 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.StrongShipsFirst); fleet1.EnterField(battleField); fleet2.EnterField(battleField); foreach (IStarShip ship in fleet2.StarShips) { ship.Health = 0; } bool result = battleField.CheckForVictory(); Assert.True(result); }
public void AttackEnemyShipsTest() { IStarShip myship = ShipFactory.CreateShip(ShipType.Fighter, ShipConfigurationType.Light); IFleet enemyfleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); var oTotalHealthAndArmor = enemyfleet.StarShips.Sum(x => x.Health) + enemyfleet.StarShips.Sum(x => x.Armor); //has random miss rate for (int i = 0; i < 100; i++) { myship.Attack(enemyfleet, BattleStratageyType.WeekShipsFirst); } var newTotalHealthAndArmor = enemyfleet.StarShips.Sum(x => x.Health) + enemyfleet.StarShips.Sum(x => x.Armor); var shipsDestroyed = enemyfleet.StarShips.Where(x => x.Health == 0).ToList(); Assert.True(oTotalHealthAndArmor > newTotalHealthAndArmor); }
private static IBattleField SetUpBattleField() { IBattleField battleField = BattleFieldFactory.CreateBattleField(BattleFieldType.Large); IFleet fleet1 = FleetFactory.CreateFleet(FleetConfigurationType.SmallShips, BattleStratageyType.WeekShipsFirst); IFleet fleet2 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.StrongShipsFirst); IFleet fleet3 = FleetFactory.CreateFleet(FleetConfigurationType.HeavyShips, BattleStratageyType.NoPriority); IFleet fleet4 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); IFleet fleet5 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.NoPriority); IFleet fleet6 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.NoPriority); fleet1.EnterField(battleField); fleet2.EnterField(battleField); fleet3.EnterField(battleField); fleet4.EnterField(battleField); fleet5.EnterField(battleField); fleet6.EnterField(battleField); return(battleField); }
public ActionResult Index(Battle battle) { battle = SessionController.GetSessionOrNewBattle(battle, Session["BattleField"]); IFleet fleet = FleetFactory.CreateFleet(battle.fleetConfigurationType, battle.battleStratageyType); if (fleet != null) { if (battle.myBattleField != null) { fleet.EnterField(battle.myBattleField); Session.Add("BattleField", battle.myBattleField); } } if (fleet != null) { return RedirectToRoute("Default", new { controller = "Battle", action = "Index" }); } return View(battle); }
public void StartBattleTest() { IBattleField battleField = BattleFieldFactory.CreateBattleField(BattleFieldType.Large); IFleet fleet1 = FleetFactory.CreateFleet(FleetConfigurationType.SmallShips, BattleStratageyType.WeekShipsFirst); IFleet fleet2 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.StrongShipsFirst); IFleet fleet3 = FleetFactory.CreateFleet(FleetConfigurationType.HeavyShips, BattleStratageyType.NoPriority); IFleet fleet4 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst); IFleet fleet5 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.NoPriority); IFleet fleet6 = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.NoPriority); fleet1.EnterField(battleField); fleet2.EnterField(battleField); fleet3.EnterField(battleField); fleet4.EnterField(battleField); fleet5.EnterField(battleField); fleet6.EnterField(battleField); battleField.StartBattle(); Assert.True(battleField.Fleets.Where(x => x.WorkingStarShips.Count() > 0).Count() == 1); bool result = battleField.CheckForVictory(); Assert.True(result); }
public void CreateSmallShipsFleetTest() { IFleet fleet = FleetFactory.CreateFleet(FleetConfigurationType.SmallShips, BattleStratageyType.WeekShipsFirst); Assert.IsType <Fleets.Fleet>(fleet); }