public void ShieldBoosterDecorateShipTest() { IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, null); var oSpeed = ship.Speed; var oHealth = ship.Health; var oPower = ship.Power; var oArmor = ship.Armor; var newImplement = DefendImplementFactory.CreateDefendImplement(DefendImplementType.ShieldBooster); DefendImplementDecorator.DecorateShip(ship, newImplement); Assert.True(ship.Speed == (oSpeed + newImplement.ShipSpeedModification) || ship.Speed == 0); Assert.True(ship.Health == (oHealth + newImplement.ShipHealthModification) || ship.Health == 0); Assert.True(ship.Power == (oPower + newImplement.ShipPowerModification) || ship.Power == 0); Assert.True(ship.Armor == (oArmor + newImplement.ShipArmorModification) || ship.Armor == 0); Assert.Equal(1, ship.DefendImplements.Count()); }
private static void SetDecorations(IStarShip ship, ShipType?shipType, ShipConfigurationType?configurationType) { if (shipType != null && configurationType != null) { IShipConfiguration conCollection = ShipConfigurationFactory.CreateShipConfiguration(shipType, configurationType); foreach (var i in conCollection.upgradeImplements) { UpgradeImplementDecorator.DecorateShip(ship, i); } foreach (var i in conCollection.defendImplements) { DefendImplementDecorator.DecorateShip(ship, i); } foreach (var i in conCollection.attackImplements) { AttackImplementDecorator.DecorateShip(ship, i); } } }