Exemplo n.º 1
0
        public void CanFindTwoWordCommand()
        {
            ParserCommand command1 = new ParserCommand("add file");
            ParserCommand command2 = new ParserCommand("add comment");
            var mapper = new CommandMapper(new[] { command1, command2 });
            mapper.State.ShouldBe(MapperState.Initial);

            mapper.Advance("add");
            mapper.State.ShouldBe(MapperState.Pending);

            mapper.Advance("comment");
            mapper.State.ShouldBe(MapperState.Accepted);
            mapper.Command.ShouldBe(command2);
        }
Exemplo n.º 2
0
        public void InvalidFirstWordRejected()
        {
            ParserCommand command1 = new ParserCommand("add file");
            ParserCommand command2 = new ParserCommand("add comment");
            var mapper = new CommandMapper(new[] { command1, command2 });
            mapper.Advance("remove");

            mapper.State.ShouldBe(MapperState.Rejected);
        }
Exemplo n.º 3
0
        public void CanFindOneAndOnly()
        {
            ParserCommand command = new ParserCommand("add");
            var mapper = new CommandMapper(new[] { command });
            mapper.Advance("add");

            mapper.State.ShouldBe(MapperState.Accepted);
            mapper.Command.ShouldBe(command);
        }
Exemplo n.º 4
0
        public void CanFindSecondOfTwo()
        {
            ParserCommand command1 = new ParserCommand("add");
            ParserCommand command2 = new ParserCommand("remove");
            var mapper = new CommandMapper(new[] { command1, command2 });
            mapper.Advance("remove");

            mapper.State.ShouldBe(MapperState.Accepted);
            mapper.Command.ShouldBe(command2);
        }
Exemplo n.º 5
0
        public void InvalidSecondWordRejected()
        {
            ParserCommand command1 = new ParserCommand("add file");
            ParserCommand command2 = new ParserCommand("add comment");
            var mapper = new CommandMapper(new[] { command1, command2 });
            mapper.Advance("add");
            mapper.State.ShouldBe(MapperState.Pending);

            mapper.Advance("junk");
            mapper.State.ShouldBe(MapperState.Rejected);
        }