示例#1
0
        public void ExecutesASimpleAction()
        {
            var sampleActions = new SampleActions();
            var context       = new ContextMock();
            var parser        = new Sidi.CommandLine.Parser();

            parser.ItemSources.Add(new Sidi.CommandLine.ItemSource(sampleActions));
            var c = new CommandLineParserActionSource(context, parser);

            var q = Query.Parse(context, "DoSomething");

            var results = c.GetActions(q).ToEnumerable().ToList();

            Assert.AreEqual(1, results.Count);
            results[0].Action.Execute();
            Assert.IsTrue(sampleActions.DoSomethingExecuted);

            q = Query.Parse(context, "Greet Hello");

            results = c.GetActions(q).ToEnumerable().ToList();

            Assert.AreEqual(1, results.Count);
            results[0].Action.Execute();
            Assert.AreEqual("Hello", sampleActions.GreetingText);
        }
示例#2
0
        public void GetActions()
        {
            var context = new ContextMock();

            Assert.AreEqual(1, af.GetActions(Query.Parse(context, "Add")).ToEnumerable().Count());
            Assert.AreEqual(0, af.GetActions(Query.Parse(context, "Bdd")).ToEnumerable().Count());
            af.GetActions(Query.Parse(context, "SomeAction")).FirstAsync().Wait().Action.Execute();
            Assert.IsTrue(sampleApp.SomeActionExecuted);
        }
示例#3
0
        public void Matches()
        {
            var sampleActions = new SampleActions();
            var context       = new ContextMock();
            var parser        = new Sidi.CommandLine.Parser();

            parser.ItemSources.Add(new Sidi.CommandLine.ItemSource(sampleActions));
            var c = new CommandLineParserActionSource(context, parser);

            AssertMatch(context, c, "del", "#SampleActions Delete");
            AssertMatch(context, c, "#sample del", "#SampleActions Delete");
        }
示例#4
0
        public void CommandLineParserActionSourceTest()
        {
            var sampleActions = new SampleActions();
            var context       = new ContextMock();

            context.SelectedPathList = new PathList(new[] { Paths.BinDir });
            var parser = new Sidi.CommandLine.Parser();

            parser.ItemSources.Add(new Sidi.CommandLine.ItemSource(sampleActions));
            var c = new CommandLineParserActionSource(context, parser);

            var results = c.GetActions(Query.Parse(context, @"File C:\temp\hello.txt")).ToEnumerable().ToList();

            Assert.AreEqual(1, results.Count);
            results[0].Action.Execute();
            Assert.IsTrue(sampleActions.FileActionExecuted);
        }