Exemplo n.º 1
0
        public void MineFieldDecorateToLargeShipTest()
        {
            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 = UpgradeImplementFactory.CreateUpgradeImplement(UpgradeImplementType.MineField);

            UpgradeImplementDecorator.DecorateShip(ship, newImplement);

            Assert.True(ship.Speed == oSpeed);
            Assert.True(ship.Health == oHealth);
            Assert.True(ship.Power == oPower);
            Assert.True(ship.Armor == oArmor);
            Assert.Equal(0, ship.UpgradeImplements.Count());
        }
Exemplo n.º 2
0
        public void WarpDriveDecorateShipTest()
        {
            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 = UpgradeImplementFactory.CreateUpgradeImplement(UpgradeImplementType.WarpDrive);

            UpgradeImplementDecorator.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.UpgradeImplements.Count());
        }
Exemplo n.º 3
0
        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);
                }
            }
        }