Exemplo n.º 1
0
        public void MaximumSpacesVisited()
        {
            int                  x = -100000, y = -100000;
            CleaningRobot        robot    = CreateTesterRobot(x, y);
            List <(string, int)> commands = new List <(string, int)>
            {
                ("E", 100000),
                ("N", 100000),
                ("W", 100000),
            };
            int z   = 99998;
            int num = 9997;

            while (num > 0)
            {
                commands.Add(("S", z));
                commands.Add(("E", z));
                z--;
                commands.Add(("N", z));
                commands.Add(("W", z));
                z--;
                num--;
            }
            robot.RunRobot(commands);
        }
Exemplo n.º 2
0
        public void InstantiationTest()
        {
            CleaningRobot robot = CreateTesterRobot(10, 22);

            Assert.AreEqual(10, robot.XCoordinate);
            Assert.AreEqual(22, robot.YCoordinate);
        }
Exemplo n.º 3
0
 private void VerifyState(CleaningRobot target, int battery, Point position, Facing facing)
 {
     Assert.AreEqual(battery, target.Battery);
     Assert.AreEqual(position.X, target.Position.X);
     Assert.AreEqual(position.Y, target.Position.Y);
     Assert.AreEqual(facing, target.Facing);
 }
Exemplo n.º 4
0
        public void MoveSouth()
        {
            int           x = 1000, y = -99, moveDistance = 10;
            CleaningRobot robot = CreateTesterRobot(x, y);

            robot.Move("S", moveDistance);
            Assert.AreEqual(y - moveDistance, robot.YCoordinate);
        }
Exemplo n.º 5
0
        public void MoveWest()
        {
            int           x = 1000, y = -99, moveDistance = 3;
            CleaningRobot robot = CreateTesterRobot(x, y);

            robot.Move("W", moveDistance);
            Assert.AreEqual(x - moveDistance, robot.XCoordinate);
        }
Exemplo n.º 6
0
 private void VerifyCleanedCell(CleaningRobot target, int x, int y)
 {
     foreach (var cell in target.CleanedCells)
     {
         if (cell.X == x && cell.Y == y)
         {
             return;
         }
     }
     Assert.Fail($"Cell {x}, {y} was not cleaned.");
 }
Exemplo n.º 7
0
        public void RunCleaningRobot_NoMovement()
        {
            int x = 12, y = 13;
            List <(string, int)> commands = new List <(string, int)>
            {
                ("E", 0)
            };
            CleaningRobot robot = CreateTesterRobot(x, y);
            int           spacesCleaned = robot.RunRobot(commands);

            Assert.AreEqual(1, spacesCleaned);
            Assert.AreEqual(12, robot.XCoordinate);
            Assert.AreEqual(13, robot.YCoordinate);
        }
Exemplo n.º 8
0
        public bool InputRobotData(string type, string name, int x, int y, int price, int distance, int power)
        {
            switch (type)
            {
            case "c":

                var newCleaningRobot = new CleaningRobot(Utils.CreateNewIndex(RobotList), name, price, x, y, distance, power);
                RobotList.Add(newCleaningRobot);
                return(true);

            case "d":

                var newDogRobot = new DogRobot(Utils.CreateNewIndex(RobotList), name, price, x, y, distance, power);
                RobotList.Add(newDogRobot);
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 9
0
        public void RunCleaningRobot_Circle()
        {
            int x = 0, y = 0;
            List <(string, int)> commands = new List <(string, int)>
            {
                ("E", 1),
                ("N", 1),
                ("W", 1),
                ("S", 1),
                ("E", 1),
                ("N", 1),
                ("W", 1),
                ("S", 1)
            };
            CleaningRobot robot = CreateTesterRobot(x, y);
            int           spacesCleaned = robot.RunRobot(commands);

            Assert.AreEqual(4, spacesCleaned);
            Assert.AreEqual(x, robot.XCoordinate);
            Assert.AreEqual(y, robot.YCoordinate);
        }
Exemplo n.º 10
0
        public void RunCleaningRobot_LargeCommandsList()
        {
            int x = -100000, y = -100000;
            List <(string, int)> commands = new List <(string, int)>
            {
                ("E", 100000),
                ("N", 100000),
                ("W", 100000),
                ("S", 99999),
                ("E", 99999),
                ("N", 99998),
                ("W", 99997),
                ("S", 99996)
            };
            CleaningRobot robot = CreateTesterRobot(x, y);
            int           spacesCleaned = robot.RunRobot(commands);

            Assert.AreEqual(799990, spacesCleaned);
            Assert.AreEqual(-99998, robot.XCoordinate);
            Assert.AreEqual(-99997, robot.YCoordinate);
        }
Exemplo n.º 11
0
 protected override void ExecuteCore(CleaningRobot robot)
 {
     robot.CleanCurrentPosition();
 }