public void UnregisterObserverTest()
        {
            IStarShip        ship             = ShipFactory.CreateShip(ShipType.Fighter, ShipConfigurationType.Balanced);
            AttackAggregator attackAggregator = new AttackAggregator();

            attackAggregator.RegisterObserver(ship);
            attackAggregator.UnregisterObserver(ship);
            Assert.Equal(0, attackAggregator.Observers.Count());
        }
        public void NotifyObserversTest()
        {
            IStarShip ship             = ShipFactory.CreateShip(ShipType.Fighter, ShipConfigurationType.Balanced);
            int       oHandA           = ship.Health + ship.Armor;
            var       attackAggregator = new AttackAggregator();

            attackAggregator.RegisterObserver(ship);
            attackAggregator.NotifyObservers(new AttackResult {
                Damage = 10
            });
            Assert.Equal(ship.Health + ship.Armor + 10, oHandA);
            attackAggregator.UnregisterObserver(ship);
        }
        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);
                }
            }
        }