public void Can_parse_ints_separated_by_multiple_spaces() { var parameterParser = new CommandParameterParser("1234 4321"); parameterParser.ParseInt().Should().Be(1234); parameterParser.ParseInt().Should().Be(4321); }
public void Throws_when_epected_int_parameter_in_wrong_format() { var parameterParser = new CommandParameterParser("1asd54"); Action action = () => parameterParser.ParseInt(); action.ShouldThrow <CommandInvocationException>(); }
public void Can_parse_ints_list_separated_by_space() { var parameterParser = new CommandParameterParser("1234 4321 9876"); parameterParser.ParseInt().Should().Be(1234); parameterParser.ParseInt().Should().Be(4321); parameterParser.ParseInt().Should().Be(9876); }
public void Throws_when_no_expected_in_parameter() { var parameterParser = new CommandParameterParser("1234 "); parameterParser.ParseInt(); Action action = () => parameterParser.ParseInt(); action.ShouldThrow <CommandInvocationException>(); }
public void TestInvalidPlaceDirection() { // arrange var paramParser = new CommandParameterParser(); string[] rawInput = "PLACE 2,4,OneDirection".Split(' '); // act and assert var exception = Assert.Throws <ArgumentException>(delegate { paramParser.ParseParameters(rawInput); }); Assert.That(exception.Message, Is.EqualTo("Invalid direction. Please select from one of the following directions: NORTH|EAST|SOUTH|WEST")); }
public void TestInvalidPlaceParamsFormat() { // arrange var paramParser = new CommandParameterParser(); string[] rawInput = "PLACE 3,3,SOUTH,2".Split(' '); // act and assert var exception = Assert.Throws <ArgumentException>(delegate { paramParser.ParseParameters(rawInput); }); Assert.That(exception.Message, Is.EqualTo("Incomplete command. Please ensure that the PLACE command is using format: PLACE X,Y,F")); }