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