public void testInsertCommand()
        {
            Scenario scenario = new Scenario(20, 20);
            Controller controller = new Controller(scenario);

            Unit unit = new Unit(scenario.getPlayer(), 200);
            controller.addUnit(unit, 10f, 10f);

            // Create a MoveAction
            MoveAction action = new MoveAction(8f, 8f, scenario.getGameWorld(), unit);

            // Test if the ActionController returns true when it gives the command.
            Assert.IsTrue(controller.giveActionCommand(unit, action));

            // Test if the MoveAction is actually on the unit's action queue.
            Assert.IsTrue(unit.getActionQueue()[0] == action);

            // Create a second MoveAction
            MoveAction action2 = new MoveAction(7f, 7f, scenario.getGameWorld(), unit);

            // Insert the second MoveAction to the beginning of the units action queue.
            ActionController.insertIntoActionQueue(unit, action2);
            Assert.IsTrue(unit.getActionQueue()[0] == action2);
            Assert.IsTrue(unit.getActionQueue()[1] == action);
        }
        public void testGiveCommand()
        {
            Scenario scenario = new Scenario(20, 20);
            Controller controller = new Controller(scenario);

            Unit unit = new Unit(scenario.getPlayer(), 200);
            controller.addUnit(unit, 10f, 10f);

            // Create a MoveAction
            MoveAction action = new MoveAction(8f, 8f, scenario.getGameWorld(), unit);

            // Test if the ActionController returns true when it gives the command.
            Assert.IsTrue(controller.giveActionCommand(unit, action));

            // Test if the MoveAction is actually on the unit's action queue.
            Assert.IsTrue(unit.getActionQueue()[0] == action);

            // Create a second MoveAction
            MoveAction action2 = new MoveAction(7f, 7f, scenario.getGameWorld(), unit);

            // Test if the ActionController interrupts the current MoveAction and replaces it with the new one.
            Assert.IsTrue(controller.giveActionCommand(unit, action2));
            Assert.IsTrue(unit.getActionQueue()[0] == action2);
            Assert.IsFalse(unit.getActionQueue().Contains(action));
        }
        public void testMapWithUnitMove()
        {
            Scenario scenario = new Scenario(20, 20);
            Controller controller = new Controller(scenario);
            Unit unit = new Unit(scenario.getPlayer(), new UnitStats());
            controller.addUnit(unit, 6, 6);

            MoveAction move = new MoveAction(10, 10, scenario.getGameWorld(), unit);

            controller.giveActionCommand(unit, move);

            // Update the world so that the unit moves.
            for (int i = 0; i < 1000; i++)
            {
                controller.updateWorld();
            }

            // Test that all of the cells within the units visibility range have been explored.
            for (int i = (int)unit.x - (int)unit.stats.visibilityRange; i < (int)unit.x + (int)unit.stats.visibilityRange; i++)
            {
                for (int j = (int)unit.y - (int)unit.stats.visibilityRange; j < (int)unit.y + (int)unit.stats.visibilityRange; j++)
                {
                    Assert.IsTrue(scenario.getGameWorld().map.getCell(i, j).explored);
                }
            }
        }
        public void testMapWithUnit()
        {
            Scenario scenario = new Scenario(20, 20);
            Controller controller = new Controller(scenario);
            Unit unit = new Unit(scenario.getPlayer(), new UnitStats());
            controller.addUnit(unit, 0, 0);

            // Test that all of the cells within the units visibility range have been explored.
            for (int i = 0; i < unit.stats.visibilityRange; i++)
            {
                for (int j = 0; j < unit.stats.visibilityRange; j++)
                {
                    Assert.IsTrue(scenario.getGameWorld().map.getCell(i, j).explored);
                }
            }
        }
        public void testMove()
        {
            Scenario scenario = new Scenario(20, 20);
            Controller controller = new Controller(scenario);

            Unit unit = new Unit(scenario.getPlayer(), 200);
            controller.addUnit(unit, 10f, 10f);

            // Create a MoveAction
            MoveAction action = new MoveAction(8f, 8f, scenario.getGameWorld(), unit);

            controller.giveActionCommand(unit, action);

            Assert.AreEqual(scenario.getGameWorld().map.getCell(10, 10), unit.getCell());

            // Run 1000 cycles of the game
            for (int i = 0; i < 1000; i++)
            {
                controller.updateWorld();
            }

            // Test if the unit has ended up in the target cell.
            Assert.AreEqual(scenario.getGameWorld().map.getCell(8, 8), unit.getCell());
        }
 private void setUpController(Scenario scenario)
 {
     this.scenario = scenario;
     this.gameWorld = this.scenario.getGameWorld();
     this.visMapLogic = new VisibilityMapLogic(scenario.getGameWorld(), scenario.getPlayer());
     this.locController = new EntityLocController(scenario, this.visMapLogic);
 }