public void TestUnitNotReactingToEnemyAddedOutsideRange()
        {
            setupModel();
            // Add a unit to each player.
            UnitList list = ((PlayerComponent)model.GetScenario().GetGameWorld().GetPlayerList().GetChildren()[0]).GetUnitList();
            UnitList list2 = ((PlayerComponent)model.GetScenario().GetGameWorld().GetPlayerList().GetChildren()[1]).GetUnitList();

            // Create a Unit for Player 1
            UnitComponent unit1 = new UnitComponent();
            list.AddChild(unit1);
            unit1.PointLocation = new PointF(0.5f, 0.5f);
            unit1.AttackStance = UnitComponent.UnitAttackStance.Aggressive;
            unit1.VisibilityRange = 4.0f;

            // Create a Unit for Player 2
            UnitComponent unit2 = new UnitComponent();
            list2.AddChild(unit2);
            unit2.PointLocation = new PointF(9.5f, 9.5f); // outisde unit1's visibility range (4.0f).

            bool output = false;
            // Check to see if unit1 noticed unit2 being added.
            if (unit1.GetActionQueue().GetChildren().Count > 0)
            {
                if (unit1.GetActionQueue().GetChildren()[0] is AttackAction)
                {
                    AttackAction action = (AttackAction)unit1.GetActionQueue().GetChildren()[0];

                    output = action.Target == unit2;
                }
            }

            Assert.IsFalse(output);
        }
        public void TestUnitReactingToEnemyAddedWithinRange()
        {
            setupModel();
            // Add a unit to each player.
            UnitList list = ((PlayerComponent)model.GetScenario().GetGameWorld().GetPlayerList().GetChildren()[0]).GetUnitList();
            UnitList list2 = ((PlayerComponent)model.GetScenario().GetGameWorld().GetPlayerList().GetChildren()[1]).GetUnitList();

            // Create a unit for Player 1
            UnitComponent unit1 = new UnitComponent();
            list.AddChild(unit1);
            unit1.PointLocation = new PointF(0.5f, 0.5f);
            unit1.AttackStance = UnitComponent.UnitAttackStance.Aggressive;

            // Create a unit for Player 2
            UnitComponent unit2 = new UnitComponent();
            list2.AddChild(unit2);
            unit2.PointLocation = new PointF(1.5f, 1.5f);

            bool output = false;
            // Check to see if unit1 noticed unit2 being added next to it and correctly gave itself an attack action.
            if (unit1.GetActionQueue().GetChildren().Count > 0)
            {
                if (unit1.GetActionQueue().GetChildren()[0] is AttackAction)
                {
                    AttackAction action = (AttackAction)unit1.GetActionQueue().GetChildren()[0];

                    output =  action.Target == unit2;
                }
            }

            // unit1 should react to unit2 being added next to it.
            Assert.IsTrue(output);
        }
        public void TestUnitReactingToEnemyMovingWithinRange()
        {
            setupModel();
            // Add a unit to each player.
            UnitList list = ((PlayerComponent)model.GetScenario().GetGameWorld().GetPlayerList().GetChildren()[0]).GetUnitList();
            UnitList list2 = ((PlayerComponent)model.GetScenario().GetGameWorld().GetPlayerList().GetChildren()[1]).GetUnitList();

            // Create a Unit for Player 1
            UnitComponent unit1 = new UnitComponent();
            list.AddChild(unit1);
            unit1.PointLocation = new PointF(0.5f, 0.5f);
            unit1.AttackStance = UnitComponent.UnitAttackStance.Aggressive;
            unit1.VisibilityRange = 4.0f;

            // Create a Unit for Player 2
            UnitComponent unit2 = new UnitComponent();
            list2.AddChild(unit2);
            unit2.PointLocation = new PointF(9.5f, 9.5f); // outisde unit1's visibility range (4.0f).

            // Check to make sure that unit1 did not notice unit2 being added.
            bool output = false;
            if (unit1.GetActionQueue().GetChildren().Count > 0)
            {
                if (unit1.GetActionQueue().GetChildren()[0] is AttackAction)
                {
                    AttackAction action = (AttackAction)unit1.GetActionQueue().GetChildren()[0];

                    output = action.Target == unit2;
                }
            }
            Assert.IsFalse(output);

            // Have unit2 move into unit1's visibility range.
            MoveAction move = new MoveAction(2.0f, 2.0f, model.GetScenario().GetGameWorld().GetMap(), unit2);

            //Have unit2 move until the move action is completed.
            while (!move.Work()) { }

            // Test that unit1 has been given an AttackAction with unit2 as the target.
            output = false;
            if (unit1.GetActionQueue().GetChildren().Count > 0)
            {
                if (unit1.GetActionQueue().GetChildren()[0] is AttackAction)
                {
                    AttackAction action = (AttackAction)unit1.GetActionQueue().GetChildren()[0];

                    output = action.Target == unit2;
                }
            }
            Assert.IsTrue(output);
        }