当前位置: 首页>>代码示例>>C#>>正文


C# CommandLineParser.ParseArgumentsStrict方法代码示例

本文整理汇总了C#中CommandLineParser.ParseArgumentsStrict方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.ParseArgumentsStrict方法的具体用法?C# CommandLineParser.ParseArgumentsStrict怎么用?C# CommandLineParser.ParseArgumentsStrict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandLineParser的用法示例。


在下文中一共展示了CommandLineParser.ParseArgumentsStrict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse_strict_bad_input_fails_and_exits_when_get_usage_is_defined

        public void Parse_strict_bad_input_fails_and_exits_when_get_usage_is_defined()
        {
            var options = new SimpleOptionsForStrict();
            var testWriter = new StringWriter();

            ReflectionUtil.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new CommandLineParser();
            var result = parser.ParseArgumentsStrict(new string[] { "--bad", "--input" }, options, testWriter);

            result.Should().BeFalse();

            var helpText = testWriter.ToString();
            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // Did we really called user help method?
            lines.Should().HaveCount(n => n == 1);
            // Verify just significant output
            lines[0].Trim().Should().Be("SimpleOptionsForStrict (user defined)");
        }
开发者ID:kopelli,项目名称:commandline,代码行数:19,代码来源:StrictFixture.cs

示例2: Parse_strict_bad_input_fails_and_exits

        public void Parse_strict_bad_input_fails_and_exits()
        {
            var options = new SimpleOptions();
            var testWriter = new StringWriter();

            ReflectionUtil.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new CommandLineParser();
            var result = parser.ParseArgumentsStrict(new string[] {"--bad", "--input"}, options, testWriter);

            result.Should().BeFalse();

            var helpText = testWriter.ToString();
            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // Did we really produced all help?
            lines.Should().HaveCount(n => n == 8);
            // Verify just significant output
            lines[5].Trim().Should().Be("-s, --string");
            lines[6].Trim().Should().Be("-i");
            lines[7].Trim().Should().Be("--switch");
        }
开发者ID:kopelli,项目名称:commandline,代码行数:21,代码来源:StrictFixture.cs

示例3: Parse_strict_bad_input_fails_and_exits_with_verbs

        public void Parse_strict_bad_input_fails_and_exits_with_verbs()
        {
            var options = new OptionsWithVerbsNoHelp();
            var testWriter = new StringWriter();

            ReflectionUtil.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new CommandLineParser();
            var result = parser.ParseArgumentsStrict(new string[] { "bad", "input" }, options, testWriter);

            result.Should().BeFalse();

            var helpText = testWriter.ToString();
            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // Did we really produced all help?
            lines.Should().HaveCount(n => n == 8);
            // Verify just significant output
            lines[5].Trim().Should().Be("add       Add file contents to the index.");
            lines[6].Trim().Should().Be("commit    Record changes to the repository.");
            lines[7].Trim().Should().Be("clone     Clone a repository into a new directory.");
        }
开发者ID:kopelli,项目名称:commandline,代码行数:21,代码来源:StrictFixture.cs


注:本文中的CommandLineParser.ParseArgumentsStrict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。