本文整理匯總了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);
}
}