本文整理汇总了C#中System.Switch.AddArgumentName方法的典型用法代码示例。如果您正苦于以下问题:C# Switch.AddArgumentName方法的具体用法?C# Switch.AddArgumentName怎么用?C# Switch.AddArgumentName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Switch
的用法示例。
在下文中一共展示了Switch.AddArgumentName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddArgumentName
public void AddArgumentName()
{
const string ArgumentName1 = "arg1";
const string ArgumentName2 = "arg2";
string[] argumentNames1 = new string[] { ArgumentName1 };
string[] argumentNames2 = new string[] { ArgumentName1, ArgumentName2 };
Switch switchObject = new Switch(Name, LongName, Description,
HasArguments, IsRequired);
// Add first argument name.
switchObject.AddArgumentName(ArgumentName1);
Assert.AreEqual(argumentNames1, switchObject.GetArgumentNames());
Assert.AreEqual(NoArgumentValues, switchObject.GetArgumentValues());
Assert.AreEqual(UnknownNumberArguments, switchObject.NumberArguments);
Assert.IsFalse(switchObject.HasEnoughValues);
Assert.IsTrue(switchObject.HasArguments);
Assert.IsTrue(switchObject.HasEnoughNames);
// Add second argument name.
switchObject.AddArgumentName(ArgumentName2);
Assert.AreEqual(argumentNames2, switchObject.GetArgumentNames());
Assert.AreEqual(NoArgumentValues, switchObject.GetArgumentValues());
Assert.AreEqual(UnknownNumberArguments, switchObject.NumberArguments);
Assert.IsFalse(switchObject.HasEnoughValues);
Assert.IsTrue(switchObject.HasArguments);
Assert.IsTrue(switchObject.HasEnoughNames);
}
示例2: HasAllNamesProperty
public void HasAllNamesProperty()
{
const string ArgumentName1 = "arg1";
const string ArgumentName2 = "arg2";
const string ArgumentName3 = "arg3";
const string ArgumentName4 = "arg4";
const int NumberArguments = 3;
// Test when number of arguments known.
Switch switchObject = new Switch(Name);
Assert.IsFalse(switchObject.HasAllNames);
switchObject = new Switch(Name, LongName, Description,
NumberArguments, IsRequired);
Assert.IsFalse(switchObject.HasAllNames);
switchObject.AddArgumentName(ArgumentName1);
Assert.IsFalse(switchObject.HasAllNames);
switchObject.AddArgumentName(ArgumentName2);
Assert.IsFalse(switchObject.HasAllNames);
switchObject.AddArgumentName(ArgumentName3);
Assert.AreEqual(NumberArguments, switchObject.NumberArgumentNames);
Assert.IsTrue(switchObject.HasAllNames);
// Add extra argument name, exceeding necessary number.
switchObject.AddArgumentName(ArgumentName4);
// Extra argument name should not be added.
Assert.AreEqual(NumberArguments, switchObject.NumberArgumentNames);
Assert.IsTrue(switchObject.HasAllNames);
// Test when number of arguments unknown.
switchObject = new Switch(Name, LongName, Description,
HasArguments, IsRequired, ArgumentName1);
Assert.IsFalse(switchObject.HasAllNames);
switchObject.AddArgumentName(ArgumentName2);
Assert.IsFalse(switchObject.HasAllNames);
}
示例3: NumberArgumentNames
public void NumberArgumentNames()
{
string[] argumentNames = new string[] { "arg1", "arg2", "arg3" };
Switch switchObject = new Switch(Name, LongName, Description,
HasArguments, IsRequired);
int numberArgumentNames = 0;
Assert.AreEqual(numberArgumentNames, switchObject.NumberArgumentNames);
foreach (string argumentName in argumentNames)
{
switchObject.AddArgumentName(argumentName);
numberArgumentNames++;
Assert.AreEqual(numberArgumentNames, switchObject.NumberArgumentNames);
}
}