Example #1
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());
        }
Example #2
0
        public void PlasmaCannonDecorateShipTest()
        {
            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 = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            AttackImplementDecorator.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.AttackImplements.Count());
        }
Example #3
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());
        }
        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());
        }
Example #5
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);
                }
            }
        }
        public void Fire(IFleet enemyFleet, BattleStratageyType battleStratageyType)
        {
            if (AmmoAvailable)
            {
                if (Ammo.HasValue)
                {
                    Ammo = Ammo - 1;
                }

                IStarShip ship = GetTargetShip(battleStratageyType, enemyFleet);
                if (ship != null)
                {
                    AttackResult result = new AttackResult {
                        Damage = CalculateDamage()
                    };
                    AttackAggregator battleAttackAggregator = new AttackAggregator();
                    battleAttackAggregator.RegisterObserver(ship);
                    battleAttackAggregator.NotifyObservers(result);
                    battleAttackAggregator.UnregisterObserver(ship);
                }
            }
        }
Example #7
0
        public StarShipServiceTest()
        {
            IStarShip starShipMock = CriarMockStarShip();

            this.starShipService = new StarShipService(starShipMock);
        }
        public void FighterNumberOfUpgradeSlotsBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, null);

            Assert.Equal(5, ship.NumberOfUpgradeSlots);
        }
        public void FighterSizeBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, null);

            Assert.Equal(70, ship.Size);
        }
        public void FighterPowerBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, null);

            Assert.Equal(100, ship.Power);
        }
Example #11
0
        public void DestroyerNumberOfUpgradeSlotsAvailableBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Destroyer, null);

            Assert.Equal(20, ship.NumberOfUpgradeSlotsAvailable);
        }
Example #12
0
        public void DestroyerNumberOfDefendSlotsBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Destroyer, null);

            Assert.Equal(50, ship.NumberOfDefendSlots);
        }
Example #13
0
        public void DestroyerHealthBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Destroyer, null);

            Assert.Equal(1000, ship.Health);
        }
Example #14
0
        public void DestroyerSizeBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Destroyer, null);

            Assert.Equal(2000, ship.Size);
        }
Example #15
0
        public void DestroyerArmorBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Destroyer, null);

            Assert.Equal(270, ship.Armor);
        }
Example #16
0
        public void FleetTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, ShipConfigurationType.Light);

            Assert.True(ship.availableAttackImplements.Count > 0);
        }
Example #17
0
 public StarShipService(IStarShip starShipFacade)
 {
     this.starShipFacade   = starShipFacade;
     this.DayConverter     = new DayConverter();
     this.calculationStops = new CalculationStops();
 }
Example #18
0
        public void FrigetArmorBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Friget, null);

            Assert.Equal(180, ship.Armor);
        }
        public void FighterArmorBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, null);

            Assert.Equal(90, ship.Armor);
        }
Example #20
0
        public void FrigetHealthBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Friget, null);

            Assert.Equal(500, ship.Health);
        }
        public void FighterHealthBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, null);

            Assert.Equal(250, ship.Health);
        }
Example #22
0
        public void FrigetNumberOfDefendSlotsBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Friget, null);

            Assert.Equal(20, ship.NumberOfDefendSlots);
        }
        public void FighterNumberOfAttackSlotsAvailableBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, null);

            Assert.Equal(15, ship.NumberOfAttackSlotsAvailable);
        }
Example #24
0
        public void FrigetNumberOfUpgradeSlotsAvailableBaseValueTest()
        {
            IStarShip ship = ShipFactory.CreateShip(ShipType.Friget, null);

            Assert.Equal(10, ship.NumberOfUpgradeSlotsAvailable);
        }