#if NDESK_OPTIONS
namespace Tests.NDesk.Options
#else
-namespace Tests.Mono.Options
+namespace MonoTests.Mono.Options
#endif
{
class FooConverter : TypeConverter {
p, v => { v.Parse (_("-n=")); });
}
+ [Test]
+ public void EnumValues ()
+ {
+ DayOfWeek a = 0;
+ OptionSet p = new OptionSet () {
+ { "a=", (DayOfWeek v) => a = v },
+ };
+ p.Parse (_ ("-a=Monday"));
+ Assert.AreEqual (a, DayOfWeek.Monday);
+ p.Parse (_ ("-a=tuesday"));
+ Assert.AreEqual (a, DayOfWeek.Tuesday);
+ p.Parse (_ ("-a=3"));
+ Assert.AreEqual (a, DayOfWeek.Wednesday);
+ p.Parse (_ ("-a=Monday,Tuesday"));
+ Assert.AreEqual (a, DayOfWeek.Monday | DayOfWeek.Tuesday);
+ Utils.AssertException (typeof (OptionException),
+ "Could not convert string `Noday' to type DayOfWeek for option `-a'.",
+ p, v => { v.Parse (_ ("-a=Noday")); });
+ }
+
[Test]
public void BooleanValues ()
{
p, v => { v.Parse (_("-a", "-b")); });
Assert.AreEqual (a, "-b");
Utils.AssertException (typeof(ArgumentNullException),
- "Argument cannot be null.\nParameter name: option",
+ "Value cannot be null.\nParameter name: option",
p, v => { v.Add ((Option) null); });
Utils.AssertException (typeof(ArgumentNullException),
- "Argument cannot be null.\nParameter name: header",
+ "Value cannot be null.\nParameter name: header",
p, v => { v.Add ((string) null); });
// bad type
p, v => { v.Parse (_("-cz", "extra")); });
Utils.AssertException (typeof(ArgumentNullException),
- "Argument cannot be null.\nParameter name: action",
+ "Value cannot be null.\nParameter name: action",
p, v => { v.Add ("foo", (Action<string>) null); });
Utils.AssertException (typeof(ArgumentException),
"Cannot provide maxValueCount of 2 for OptionValueType.None.\nParameter name: maxValueCount",
Utils.AssertException (typeof(ArgumentException), "prototypes must be null!",
p, v => { v.Add ("N|NUM=", (int n) => {}); });
Utils.AssertException (typeof(ArgumentNullException),
- "Argument cannot be null.\nParameter name: option",
+ "Value cannot be null.\nParameter name: option",
p, v => { v.GetOptionForName (null); });
}