Exemplo n.º 1
0
 def test_zone_knows_coordinate_is_out_of_bounds(self):
     test_zone = Zone((2, 2))
     self.assertFalse(test_zone.is_coordinate_in_safe_zone((3, 1)))
     self.assertFalse(test_zone.is_coordinate_in_safe_zone((1, 3)))
     self.assertFalse(test_zone.is_coordinate_in_safe_zone((3, 3)))
     self.assertFalse(test_zone.is_coordinate_in_safe_zone((-1, 1)))
     self.assertFalse(test_zone.is_coordinate_in_safe_zone((1, -1)))
Exemplo n.º 2
0
 def test_execute_command_sequence_throws_exception_when_trying_to_go_out_of_bounds(
         self):
     with self.assertRaises(DangerousMoveException):
         rover = Rover((1, 1), "N", Zone((5, 5)))
         rover.save_command_sequence("MMLMM")
         rover.execute_command_sequence()
         self.fail("A DangerousMoveException should have been thrown")
Exemplo n.º 3
0
 def setUp(self):
     self.safe_zone = Zone((2, 2))
Exemplo n.º 4
0
 def test_execute_command_sequence(self):
     rover = Rover((1, 1), "N", Zone((5, 5)))
     rover.save_command_sequence("MMLM")
     rover.execute_command_sequence()
     self.assertEqual(rover.position, (0, 3))
Exemplo n.º 5
0
from MarsRover.InputParser import parse_input
from MarsRover.Rover import Rover
from MarsRover.Zone import Zone
from MarsRover.RoverController import RoverController

if __name__ == '__main__':
    # TODO: handle file location in OS generic way
    instruction_file = "example-input-file.txt"
    grid_size, starting_position, command_sequence = parse_input(instruction_file)

    rover_zone = Zone(grid_size)
    rover = Rover(starting_position["coordinate"], starting_position["bearing"], rover_zone)

    rover_controller = RoverController(rover)
    rover_controller.transmit_command_sequence_to_rover(command_sequence)
    rover_controller.instruct_rover_to_execute_command_sequence()
 def test_is_command_sequence_safe_returns_true_for_safe_movement(self):
     rover = Rover((1, 1), "N", Zone((3, 3)))
     rover_controller = RoverController(rover)
     self.assertTrue(rover_controller.is_command_sequence_safe("MRM"))
 def test_is_command_sequence_safe_returns_false_for_unsafe_movement(self):
     rover = Rover((1, 1), "N", Zone((3, 1)))
     rover_controller = RoverController(rover)
     self.assertFalse(rover_controller.is_command_sequence_safe("M"))
Exemplo n.º 8
0
 def test_zone_knows_coordinate_is_in_bounds(self):
     test_zone = Zone((2, 2))
     self.assertTrue(test_zone.is_coordinate_in_safe_zone((1, 1)))