Пример #1
0
        public void TestAddChildOverwritesCommand()
        {
            var node = GetCommandNode();

            node.AddChild(LiteralArgumentBuilder <object> .LiteralArgument("child").Build());
            node.AddChild(LiteralArgumentBuilder <object> .LiteralArgument("child").Executes(_command).Build());

            node.Children.First().Command.Should().Be(_command);
        }
Пример #2
0
        public void TestFindNodeExists()
        {
            var bar = LiteralArgumentBuilder <object> .LiteralArgument("bar").Build();

            _subject.Register(r => r.Literal("foo").Then(bar));

            _subject.FindNode(new List <string> {
                "foo", "bar"
            }).Should().Be(bar);
        }
Пример #3
0
        public void TestGetPath()
        {
            var bar = LiteralArgumentBuilder <object> .LiteralArgument("bar").Build();

            _subject.Register(r => r.Literal("foo").Then(bar));

            _subject.GetPath(bar).Should().BeEquivalentTo(new List <string> {
                "foo", "bar"
            });
        }
Пример #4
0
        public void TestAddChild()
        {
            var node = GetCommandNode();



            node.AddChild(LiteralArgumentBuilder <object> .LiteralArgument("child1").Build());
            node.AddChild(LiteralArgumentBuilder <object> .LiteralArgument("child2").Build());
            node.AddChild(LiteralArgumentBuilder <object> .LiteralArgument("child1").Build());

            node.Children.Should().HaveCount(2);
        }
Пример #5
0
        public override IArgumentBuilder <TSource, CommandNode <TSource> > CreateBuilder()
        {
            var builder = LiteralArgumentBuilder <TSource> .LiteralArgument(Literal);

            builder.Requires(Requirement);
            builder.Forward(Redirect, RedirectModifier, IsFork);
            if (Command != null)
            {
                builder.Executes(Command);
            }

            return(builder);
        }
Пример #6
0
        public void TestAddChildMergesGrandchildren()
        {
            var node = GetCommandNode();

            node.AddChild(LiteralArgumentBuilder <object> .LiteralArgument("child")
                          .Then(r => r.Literal("grandchild1"))
                          .Build());

            node.AddChild(LiteralArgumentBuilder <object> .LiteralArgument("child")
                          .Then(r => r.Literal("grandchild2"))
                          .Build());

            node.Children.Should().HaveCount(1);
            node.Children.First().Children.Should().HaveCount(2);
        }
Пример #7
0
 public void TestEquals()
 {
     new EqualsTester()
     .AddEqualityGroup(
         new RootCommandNode <object>(),
         new RootCommandNode <object>()
         )
     .AddEqualityGroup(
         new RootCommandNode <object> {
         LiteralArgumentBuilder <object> .LiteralArgument("foo").Build(),
     },
         new RootCommandNode <object> {
         LiteralArgumentBuilder <object> .LiteralArgument("foo").Build()
     }
         )
     .TestEquals();
 }
Пример #8
0
        public void TestEquals()
        {
            var command = Substitute.For <Command <object> >();

            new EqualsTester()
            .AddEqualityGroup(
                LiteralArgumentBuilder <object> .LiteralArgument("foo").Build(),
                LiteralArgumentBuilder <object> .LiteralArgument("foo").Build()
                )
            .AddEqualityGroup(
                LiteralArgumentBuilder <object> .LiteralArgument("bar").Executes(command).Build(),
                LiteralArgumentBuilder <object> .LiteralArgument("bar").Executes(command).Build()
                )
            .AddEqualityGroup(
                LiteralArgumentBuilder <object> .LiteralArgument("bar").Build(),
                LiteralArgumentBuilder <object> .LiteralArgument("bar").Build()
                )
            .AddEqualityGroup(
                LiteralArgumentBuilder <object> .LiteralArgument("foo").Then(LiteralArgumentBuilder <object> .LiteralArgument("bar")).Build(),
                LiteralArgumentBuilder <object> .LiteralArgument("foo").Then(LiteralArgumentBuilder <object> .LiteralArgument("bar")).Build()
                )
            .TestEquals();
        }
Пример #9
0
        public LiteralCommandNodeTest()
        {
            _node = LiteralArgumentBuilder <object> .LiteralArgument("foo").Build();

            _contextBuilder = new CommandContextBuilder <object>(new CommandDispatcher <object>(), new object(), new RootCommandNode <object>(), 0);
        }