本文整理汇总了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)");
}
示例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");
}
示例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.");
}