Пример #1
0
        private InputModel build(params string[] tokens)
        {
            var queue = new Queue <string>(tokens);
            var graph = new UsageGraph("fubu", typeof(InputCommand));

            return((InputModel)graph.BuildInput(queue));
        }
Пример #2
0
        public void derive_a_single_usage_for_any_command_that_has_no_specific_usages()
        {
            var graph = new UsageGraph(typeof(SimpleCommand));
            var usage = graph.Usages.Single();

            usage.Description.ShouldBe(typeof(SimpleCommand).GetAttribute <DescriptionAttribute>().Description);
            usage.Arguments.Select(x => x.MemberName).ShouldHaveTheSameElementsAs("Arg1", "Arg2");
        }
Пример #3
0
        public void RefreshUsages()
        {
            // TODO -- show progress
            var usageGraph = new UsageGraph(_context.Library, new ConsoleUsageGraphListener());

            usageGraph.Rebuild(_suite.GetAllTests());

            _view.ShowFixtureUsage(usageGraph.AllFixtures());
        }
Пример #4
0
        private CommandRun buildRun(Queue <string> queue, string commandName)
        {
            var usages = new UsageGraph(_commandTypes[commandName]);

            try
            {
                var input = usages.BuildInput(queue, _commandCreator);

                BeforeBuild?.Invoke(commandName, input);

                var command = Build(commandName);

                var run = new CommandRun
                {
                    Command = command,
                    Input   = input
                };

                ConfigureRun(run);

                return(run);
            }
            catch (InvalidUsageException e)
            {
                ConsoleWriter.Write(ConsoleColor.Red, "Invalid usage");


                if (e.Message.IsNotEmpty())
                {
                    ConsoleWriter.Write(ConsoleColor.Yellow, e.Message);
                }

                Console.WriteLine();
            }
            catch (Exception e)
            {
                ConsoleWriter.Write(ConsoleColor.Red, "Error parsing input");
                ConsoleWriter.Write(ConsoleColor.Yellow, e.ToString());

                Console.WriteLine();
            }

            return(HelpRun(commandName));
        }
        public void all_commands_usage_graph_works()
        {
            var factory = new CommandFactory();

            factory.RegisterCommands(typeof(IFubuCommand).Assembly);

            factory.AllCommandTypes().Each(t =>
            {
                try
                {
                    var usageGraph = new UsageGraph(t);
                    usageGraph.WriteUsages("fubu");

                    usageGraph.Usages.Any().ShouldBeTrue();
                }
                catch (Exception e)
                {
                    throw new ApplicationException("Command type:  " + t.FullName, e);
                }
            });
        }
Пример #6
0
 protected OaktonAsyncCommand()
 {
     Usages = new UsageGraph(GetType());
 }
Пример #7
0
 public void SetUp()
 {
     theUsageGraph = new UsageGraph("fubu", typeof(FakeLinkCommand));
 }
Пример #8
0
 public void SetUp()
 {
     theUsageGraph = new UsageGraph("derp", typeof(ComplexCommand));
 }
Пример #9
0
 public void SetUp()
 {
     theUsageGraph = new FakeLinkCommand().Usages;
 }
Пример #10
0
 public void SetUp()
 {
     runner = new ProjectTestRunner(DataMother.THE_GRAMMAR_FILE);
     usages = new UsageGraph(runner.GetLibary(), new ConsoleUsageGraphListener());
     usages.Rebuild(runner.Hierarchy);
 }