[InlineData(5, 5, "W", 'M', "4 5 W")] //heading east, move, expected x - 1 public void Rover_ExecuteCommand_move_changes_position(int x, int y, string heading, Char command, string expected) { //arrange var rover = new Library.Rover(10, 10, x, y, heading); //act rover.ExecuteCommand(command, new Library.Rover[0]); //assert var actual = rover.ReportPosition(); actual.ShouldBe(expected); }
[InlineData(5, 5, 0, 2, "W", 'M', "0 2 W")] //rover facing west on left edge public void Rover_ExecuteCommand_on_plateau_edge_ignores_command_that_would_move_it_off_the_plateau(int width, int height, int x, int y, string heading, Char command, string expected) { //arrange var rover = new Library.Rover(width, height, x, y, heading); //act rover.ExecuteCommand(command, new Library.Rover[0]); //assert var actual = rover.ReportPosition(); actual.ShouldBe(expected); }
[InlineData(2, 3, "S", "2 3 S")] //to the North, facing South public void Rover_ExecuteCommand_ignores_command_that_would_cause_collision_with_another_rover(int x, int y, string heading, string expected) { //arrange an existing rover at x,y 2,2 var otherRovers = new Library.Rover[] { new Library.Rover(5, 5, 2, 2, "N") }; var roverToMove = new Library.Rover(5, 5, x, y, heading); //act roverToMove.ExecuteCommand('M', otherRovers); //assert var actual = roverToMove.ReportPosition(); actual.ShouldBe(expected); }