public void ConvertFrom_InvalidString_PlusSignAtTheBeginning() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); object o = null; AssertExtensions.Throws <ArgumentException>(null, () => o = cv.ConvertFrom(null, null, "+Foo")); Assert.Null(o); }
public void ConvertFrom_InvalidString_WhiteSpaceAtTheEnd() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); object o = null; AssertExtensions.Throws <ArgumentException>(null, () => o = cv.ConvertFrom(null, null, "Foo ")); Assert.Null(o); }
public void ConvertFrom_EmptyString() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); object o = null; AssertExtensions.Throws <ArgumentException>(null, () => o = cv.ConvertFrom(null, null, string.Empty)); Assert.Null(o); }
public void ConvertFrom_Null() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); object o; o = cv.ConvertFrom(null, null, null); Assert.IsNull(o, "A1"); }
public void ConvertFrom_InvalidString() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); object o = null; Assert.Throws <ArgumentException>(() => o = cv.ConvertFrom(null, null, "baz")); Assert.Null(o); }
public void CanConvertTo() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); Assert.IsTrue(cv.CanConvertTo(null, typeof(string)), "A1"); Assert.IsFalse(cv.CanConvertTo(null, typeof(TimeSpan)), "A2"); Assert.IsFalse(cv.CanConvertTo(null, typeof(int)), "A3"); Assert.IsFalse(cv.CanConvertTo(null, typeof(object)), "A4"); }
public void ConvertFrom_Case() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); Assert.AreEqual(FooEnum.Foo, cv.ConvertFrom(null, null, "foo"), "A1"); }
public void Ctor_TypeError() { GenericEnumConverter cv = new GenericEnumConverter(typeof(object)); }
public void Ctor_Null() { GenericEnumConverter cv = new GenericEnumConverter(null); }
public void ConvertTo_TypeError2() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); Assert.AreEqual("", cv.ConvertTo(null, null, "", typeof(string)), "A1"); }
public void ConvertFrom_Case() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); AssertExtensions.Throws <ArgumentException>(null, () => cv.ConvertFrom(null, null, "foo")); }
public void ConvertTo_TypeError1() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); Assert.Equal("0", cv.ConvertTo(null, null, 0, typeof(string))); }
public void ConvertTo_NullError() { GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum)); Assert.Throws <NullReferenceException>(() => cv.ConvertTo(null, null, null, typeof(string))); }