Пример #1
0
        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);
        }
Пример #2
0
        public void Throws_when_epected_int_parameter_in_wrong_format()
        {
            var parameterParser = new CommandParameterParser("1asd54");

            Action action = () => parameterParser.ParseInt();

            action.ShouldThrow <CommandInvocationException>();
        }
Пример #3
0
        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);
        }
Пример #4
0
        public void Throws_when_no_expected_in_parameter()
        {
            var parameterParser = new CommandParameterParser("1234 ");

            parameterParser.ParseInt();
            Action action = () => parameterParser.ParseInt();

            action.ShouldThrow <CommandInvocationException>();
        }
Пример #5
0
        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"));
        }
Пример #6
0
        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"));
        }