本文整理汇总了C#中OptionSet.AddVariableList方法的典型用法代码示例。如果您正苦于以下问题:C# OptionSet.AddVariableList方法的具体用法?C# OptionSet.AddVariableList怎么用?C# OptionSet.AddVariableList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionSet
的用法示例。
在下文中一共展示了OptionSet.AddVariableList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_process_variablelists
public void Should_process_variablelists()
{
var p = new OptionSet();
var n = p.AddVariableList<string>("n", "");
var a = p.AddVariableList<int>("a", "");
var myArgs = "-n FindThisString -n:Findit2 -n:Findi3 -a2 -a3 -a5565 -a:23".Split(' ');
p.Parse(myArgs);
Assert.AreEqual(3, n.Values.Count());
Assert.AreEqual(4, a.Values.Count());
Assert.IsTrue(n.Values.Contains("FindThisString"));
Assert.IsTrue(a.Values.Contains(23));
}
示例2: Should_Process_VariableLists
public void Should_Process_VariableLists()
{
var optionSet = new OptionSet();
var n = optionSet.AddVariableList<string>("n", "");
var a = optionSet.AddVariableList<int>("a", "");
//TODO: Screaming for an NUnit-test-case-coverage.
var args = "-n FindThisString -n:Findit2 -n:Findi3 -a2 -a3 -a5565 -a:23".Split(' ');
optionSet.Parse(args);
Action<IEnumerable<int>> verifyA = x =>
{
// ReSharper disable PossibleMultipleEnumeration
Assert.AreEqual(4, x.Count());
Assert.IsTrue(x.Contains(23));
// ReSharper restore PossibleMultipleEnumeration
};
Action<IEnumerable<string>> verifyN = x =>
{
// ReSharper disable PossibleMultipleEnumeration
Assert.AreEqual(3, x.Count());
Assert.IsTrue(x.Contains("FindThisString"));
// ReSharper restore PossibleMultipleEnumeration
};
verifyA(a);
verifyA(a.Values);
verifyN(n);
verifyN(n.Values);
}