예제 #1
0
        public UsageComposerFacts()
        {
            this.arguments         = new List <IArgument>();
            this.requiredArguments = new List <IArgument>();
            this.longAliases       = new Dictionary <string, IArgumentWithName>();
            this.help = new List <Help.Help>();

            var configuration = new CommandLineConfiguration(
                this.arguments,
                this.longAliases,
                this.requiredArguments,
                this.help);

            this.testee = new UsageComposer(configuration);
        }
예제 #2
0
        public void UnknownArgument(
            string[] args,
            CommandLineConfiguration configuration,
            UsageComposer usageComposer,
            Usage usage)
        {
            "establish a parsing configuration".x(() =>
            {
                configuration = CommandLineParserConfigurator
                                .Create()
                                .WithNamed("optional", Dummy)
                                .DescribedBy("placeholder", "optional description")
                                .WithNamed("required", Dummy)
                                .Required()
                                .DescribedBy("placeholder", "required description")
                                .BuildConfiguration();
            });

            "establish a usage composer using the parsing configuration".x(() =>
            {
                usageComposer = new UsageComposer(configuration);
            });

            "when composing usage".x(() =>
                                     usage = usageComposer.Compose());

            "should list arguments".x(() =>
                                      usage.Arguments
                                      .Should().Contain("-optional <placeholder>")
                                      .And.Contain("-required <placeholder>"));

            "should show whether an argument is optional or required".x(() =>
                                                                        (usage.Arguments + " ")
                                                                        .Should().Contain("[-optional <placeholder>]")
                                                                        .And.Contain(" -required <placeholder> "));

            "should list options per argument with description".x(() =>
                                                                  usage.Options
                                                                  .Should().Contain("optional description")
                                                                  .And.Contain("required description"));
        }