public async Task Should_move_rover_to_the_expected_position(int expectedX, int expectedY, params MovementType[] movements) { var rover = new Rover(FacingDirection.N, new Position(0, 0)); var expectedPosition = new Position(expectedX, expectedY); var command = new MoveRoverCommand { Rover = rover, Movements = new List <MovementType>(movements), Plateau = new Plateau(5, 5) }; var commandHandler = new MoveRoverCommandHandler(); await commandHandler.Handle(command, CancellationToken.None); rover.Position.Should().Be(expectedPosition); }
[InlineData(MovementType.Right, MovementType.Forward, MovementType.Forward, MovementType.Right, MovementType.Forward)] //off-grid (2, -1) public async Task Should_stop_moving_if_the_next_movement_is_off_grid(params MovementType[] movements) { var rover = new Rover(FacingDirection.N, new Position(0, 0)); var command = new MoveRoverCommand { Rover = rover, Movements = new List <MovementType>(movements), Plateau = new Plateau(2, 2) }; var commandHandler = new MoveRoverCommandHandler(); Func <Task> commandAct = async() => { await commandHandler.Handle(command, CancellationToken.None); }; await commandAct.Should().ThrowAsync <OffGridMovementException>(); }