Exemplo n.º 1
0
        public void TestMove(string movements, char direction, int startX, int startY, int finalX, int finalY)
        {
            Grid world = new Grid(10, 10);

            Rover rover = new Rover(startX, startY, direction);

            world.GridCellAt(3, 5).ContainsObstacle = true;
            world.GridCellAt(3, 6).ContainsObstacle = true;
            world.GridCellAt(1, 8).ContainsObstacle = true;
            world.GridCellAt(7, 4).ContainsObstacle = true;
            world.GridCellAt(6, 2).ContainsObstacle = true;

            rover.World = world;

            foreach (char movement in movements)
            {
                if (!rover.Move(movement))
                {
                    break;
                }
            }

            Console.WriteLine("Final Location: " + rover.CurrentLocation.X + " " + rover.CurrentLocation.Y);

            Assert.AreEqual(finalX, rover.CurrentLocation.X);
            Assert.AreEqual(finalY, rover.CurrentLocation.Y);
        }
Exemplo n.º 2
0
        public void TestGridCellAt(int x, int y, int expectedX, int expectedY)
        {
            Grid grid = new Grid(10, 10);

            GridCell gridCell = grid.GridCellAt(x, y);

            Assert.AreEqual(expectedX, gridCell.X);
            Assert.AreEqual(expectedY, gridCell.Y);
        }
Exemplo n.º 3
0
        private static Grid CreateWorld()
        {
            Grid world = new Grid(10, 10);

            world.GridCellAt(3, 5).ContainsObstacle = true;
            world.GridCellAt(3, 6).ContainsObstacle = true;
            world.GridCellAt(1, 8).ContainsObstacle = true;
            world.GridCellAt(7, 4).ContainsObstacle = true;
            world.GridCellAt(6, 2).ContainsObstacle = true;

            return world;
        }
Exemplo n.º 4
0
 public void Setup()
 {
     grid = new Grid(10, 10, new List<Coordinate>());
 }
Exemplo n.º 5
0
 public void Setup()
 {
     obstacles = new List<Coordinate>();
     obstacles.Add(new Coordinate(5, 5));
     grid = new Grid(10, 10, obstacles);
 }