本文整理汇总了C#中CommandLineParser.WasVerbOptionInvoked方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.WasVerbOptionInvoked方法的具体用法?C# CommandLineParser.WasVerbOptionInvoked怎么用?C# CommandLineParser.WasVerbOptionInvoked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandLineParser
的用法示例。
在下文中一共展示了CommandLineParser.WasVerbOptionInvoked方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Failed_parsing_prints_help_index
public void Failed_parsing_prints_help_index()
{
var options = new OptionsWithVerbs();
var testWriter = new StringWriter();
var parser = new CommandLineParser();
var result = parser.ParseArguments(new string[] {}, options, testWriter);
result.Should().BeFalse();
parser.WasVerbOptionInvoked("add").Should().BeFalse();
parser.WasVerbOptionInvoked("commit").Should().BeFalse();
parser.WasVerbOptionInvoked("clone").Should().BeFalse();
var helpText = testWriter.ToString();
helpText.Should().Be("verbs help index");
}
示例2: Failed_verb_parsing_prints_particular_help_screen
public void Failed_verb_parsing_prints_particular_help_screen()
{
var options = new OptionsWithVerbs();
var testWriter = new StringWriter();
var parser = new CommandLineParser();
var result = parser.ParseArguments(new string[] {"clone", "--no_hardlinks"}, options, testWriter);
result.Should().BeFalse();
parser.WasVerbOptionInvoked("add").Should().BeFalse();
parser.WasVerbOptionInvoked("commit").Should().BeFalse();
// The following returns true because also if the parser fail 'clone' was invoked.
parser.WasVerbOptionInvoked("clone").Should().BeTrue();
var helpText = testWriter.ToString();
helpText.Should().Be("help for: clone");
}
示例3: Parse_verbs_create_instance
public void Parse_verbs_create_instance()
{
var options = new OptionsWithVerbs();
options.AddVerb.Should().BeNull();
var parser = new CommandLineParser();
var result = parser.ParseArguments(new string[] {"add", "-p", "untracked.bin"} , options);
result.Should().BeTrue();
parser.WasVerbOptionInvoked("add").Should().BeTrue();
parser.WasVerbOptionInvoked("commit").Should().BeFalse();
parser.WasVerbOptionInvoked("clone").Should().BeFalse();
// Parser has built instance for us
options.AddVerb.Should().NotBeNull();
options.AddVerb.CreationProof.Should().NotHaveValue();
options.AddVerb.Patch.Should().BeTrue();
options.AddVerb.FileName[0].Should().Be("untracked.bin");
}
示例4: Was_verb_option_invoked_returns_false_with_ordinary_options
public void Was_verb_option_invoked_returns_false_with_ordinary_options()
{
var options = new OptionsWithVerbs();
var parser = new CommandLineParser();
var result = parser.ParseArguments(new string[] {"commit", "--amend"}, options);
result.Should().BeTrue();
parser.WasVerbOptionInvoked("--commit").Should().BeFalse();
parser.WasVerbOptionInvoked("-commit").Should().BeFalse(); // <- pure fantasy
parser.WasVerbOptionInvoked("-c").Should().BeFalse();
parser.WasVerbOptionInvoked("---commit").Should().BeFalse(); // <- pure fantasy
parser.WasVerbOptionInvoked("--amend").Should().BeFalse();
parser.WasVerbOptionInvoked("-a").Should().BeFalse();
}
示例5: Was_verb_option_invoked_returns_false_with_null_or_empty_verb
public void Was_verb_option_invoked_returns_false_with_null_or_empty_verb()
{
var options = new OptionsWithVerbs();
var parser = new CommandLineParser();
var result = parser.ParseArguments(new string[] {"commit", "--amend"}, options);
result.Should().BeTrue();
parser.WasVerbOptionInvoked(null).Should().BeFalse();
parser.WasVerbOptionInvoked("").Should().BeFalse();
}
示例6: Was_verb_option_invoked_returns_false_with_empty_arguments
public void Was_verb_option_invoked_returns_false_with_empty_arguments()
{
var options = new OptionsWithVerbs();
var parser = new CommandLineParser();
var result = parser.ParseArguments(new string[] {}, options);
result.Should().BeFalse();
parser.WasVerbOptionInvoked("add").Should().BeFalse();
parser.WasVerbOptionInvoked("commit").Should().BeFalse();
parser.WasVerbOptionInvoked("clone").Should().BeFalse();
}
示例7: Parse_verbs_using_instance
public void Parse_verbs_using_instance()
{
var proof = new Random().Next(int.MaxValue);
var options = new OptionsWithVerbs();
options.CommitVerb.Should().NotBeNull();
options.CommitVerb.CreationProof = proof;
var parser = new CommandLineParser();
var result = parser.ParseArguments(new string[] { "commit", "--amend" }, options);
result.Should().BeTrue();
parser.WasVerbOptionInvoked("add").Should().BeFalse();
parser.WasVerbOptionInvoked("commit").Should().BeTrue();
parser.WasVerbOptionInvoked("clone").Should().BeFalse();
// Check if the instance is the one provider by us (not by the parser)
options.CommitVerb.CreationProof.Should().Be(proof);
options.CommitVerb.Amend.Should().BeTrue();
}