Пример #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 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");
        }
Пример #3
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);
        }