Exemple #1
0
        public void CalculateDamageTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);
            int maxvalue = attackImplement.Power * 4;

            Assert.True(attackImplement.CalculateDamage() <= maxvalue);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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 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 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);
        }
Exemple #6
0
        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);
        }
Exemple #7
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());
        }
        public void MissileAmmoBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(4, attackImplement.Ammo);
        }
        public void MissileHealthBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(100, attackImplement.Health);
        }
        public void PlasmaCannonAmmoBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.Equal(100, attackImplement.Ammo);
        }
 public void CreateLaserImplementTest()
 {
     Assert.IsType <LaserImplement>(AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser));
 }
Exemple #12
0
        public void PhotonTorpedoSizeBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.Equal(4, attackImplement.Size);
        }
Exemple #13
0
        public void PhotonTorpedoPowerBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.Equal(2, attackImplement.Power);
        }
 public void CreateAttackImplementNullTest()
 {
     Assert.Equal(null, AttackImplementFactory.CreateAttackImplement(null));
 }
 public void CreatePlasmaCannonImplementTest()
 {
     Assert.IsType <PlasmaCannonImplement>(AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon));
 }
 public void CreatePhotonTorpedoImplementTest()
 {
     Assert.IsType <PhotonTorpedoImplement>(AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo));
 }
 public void CreateMissileImplementTest()
 {
     Assert.IsType <MissileImplement>(AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile));
 }
        public void MissileAmmoAvailableTest()
        {
            IAttackImplement i = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.True(i.AmmoAvailable);
        }
        public void MissileShipSpeedModificationBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(-2, attackImplement.ShipSpeedModification);
        }
        public void PlasmaCannonPowerBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.Equal(2, attackImplement.Power);
        }
Exemple #21
0
        public void PhotonTorpedoAmmoBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.Equal(10, attackImplement.Ammo);
        }
        public void LaserShipSpeedModificationBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);

            Assert.Equal(-1, attackImplement.ShipSpeedModification);
        }
Exemple #23
0
        public void PhotonTorpedoAmmoAvailableTest()
        {
            IAttackImplement i = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.True(i.AmmoAvailable);
        }
Exemple #24
0
        public void PhotonTorpedoShipSpeedModificationBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.Equal(-3, attackImplement.ShipSpeedModification);
        }
        public void PlasmaCannonSizeBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.Equal(8, attackImplement.Size);
        }
        public void MissilePowerBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(1, attackImplement.Power);
        }
        public void PlasmaCannonAmmoAvailableTest()
        {
            IAttackImplement i = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.True(i.AmmoAvailable);
        }
        public void MissileSizeBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(2, attackImplement.Size);
        }
        public void PlasmaCannonShipSpeedModificationBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.Equal(-4, attackImplement.ShipSpeedModification);
        }
        public void LaserAmmoBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);

            Assert.Equal(false, attackImplement.Ammo.HasValue);
        }