public async Task ShouldThrowIfRoverInitialPositionIsOutsideTerrain( params int[] roverPos) { var parser = new CommandLineInputParser( new[] { "5 5", $"{roverPos[0]} {roverPos[1]} n", "lmx" }); await Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => parser.GetAll()); }
public async Task ShouldFilterOutInvalidMovementCommands() { var invalidCommand = "x"; var validCommands = "lm"; var parser = new CommandLineInputParser( new[] { "5 5", "1 2 n", $"{invalidCommand}{validCommands}" }); var commandParameters = await parser.GetAll(); commandParameters.First().ManouvreCommands .Should() .HaveCount(2); commandParameters.First().ManouvreCommands .Should() .ContainInOrder( RoverCommands.TurnLeft, RoverCommands.Move); }
public async Task ShouldReturnMultipleCommandParametersForMultiRoverCommandInput() { var parser = new CommandLineInputParser( new[] { "5 5", "1 2 n", "lml", "3 3 e", "mmr" }); var commands = await parser.GetAll(); commands.Should().HaveCount(2); var command = commands.First(); command.Terrain.MaxX.Should().Be(5); command.Terrain.MaxY.Should().Be(5); command.RoverInitialisationParameters.CurrentRoverPositionX.Should().Be(1); command.RoverInitialisationParameters.CurrentRoverPositionY.Should().Be(2); command.RoverInitialisationParameters.CurrentRoverHeading.Should().Be(Direction.North); command.ManouvreCommands.Count().Should().Be(3); command.ManouvreCommands.Should() .ContainInOrder( RoverCommands.TurnLeft, RoverCommands.Move, RoverCommands.TurnLeft); var command2 = commands.Last(); command2.Terrain.MaxX.Should().Be(5); command2.Terrain.MaxY.Should().Be(5); command2.RoverInitialisationParameters.CurrentRoverPositionX.Should().Be(3); command2.RoverInitialisationParameters.CurrentRoverPositionY.Should().Be(3); command2.RoverInitialisationParameters.CurrentRoverHeading.Should().Be(Direction.East); command2.ManouvreCommands.Count().Should().Be(3); command2.ManouvreCommands.Should() .ContainInOrder( RoverCommands.Move, RoverCommands.Move, RoverCommands.TurnRight); }
public async Task ShouldThrowIfCommandsInvalid(params string[] badCommandLineArgs) { var parser = new CommandLineInputParser(badCommandLineArgs); await Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => parser.GetAll()); }