Example #1
0
 public void Can_initialize_rover()
 {
     var startingLoc = new Location(2.0m, 3.0m);
     var startingDir = 'N';
     var grid = new Grid(3, 3);
     var rover = new Rover(grid, startingLoc, startingDir);
     rover.ShouldNotBeNull();
 }
Example #2
0
        public void Can_receive_a_move_command()
        {
            var loc = new Location(1.0m, 1.0m);
            var startingDir = 'N';
            var grid = new Grid(3, 3);
            var rover = new Rover(grid, loc, startingDir);

            rover.ProcessCommand('b');
            rover.location.latitude.ShouldEqual(0.0m);
        }
Example #3
0
        public void Can_receive_array_of_commands()
        {
            var loc = new Location(1.0m, 1.0m);
            var startingDir = 'N';
            var grid = new Grid(3, 3);
            var rover = new Rover(grid, loc, startingDir);

            rover.ProcessCommands(new []{'r', 'f', 'l', 'f', 'f'});
            rover.location.latitude.ShouldEqual(3.0m);
            rover.location.longitude.ShouldEqual(2.0m);
            rover.direction.ShouldEqual('N');
        }
Example #4
0
        public void Can_move_from_any_direction()
        {
            var loc = new Location(1.0m, 1.0m);
            var grid = new Grid(3, 3);
            var rover1 = new Rover(grid, loc, 'S');

            rover1.ProcessCommand('f');
            rover1.location.latitude.ShouldEqual(0.0m);

            var rover2 = new Rover(grid, loc, 'W');
            rover2.ProcessCommand('b');
            rover2.location.longitude.ShouldEqual(2.0m);
        }
Example #5
0
        public void Grid_wraps_movement_when_outside_bounds()
        {
            var loc = new Location(3.0m, 3.0m);
            var grid = new Grid(3, 3);

            var rover = new Rover(grid, loc, 'N');

            rover.ProcessCommand('f');
            rover.location.latitude.ShouldEqual(0.0m);
            rover.location.longitude.ShouldEqual(3.0m);
        }
Example #6
0
        public void Can_receive_a_turn_command()
        {
            var loc = new Location(1.0m, 1.0m);
            var startingDir = 'N';
            var grid = new Grid(3, 3);
            var rover = new Rover(grid, loc, startingDir);

            rover.ProcessCommand('r');
            rover.direction.ShouldEqual('E');
        }