Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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");
        }
Example #5
0
        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);
        }
Example #6
0
        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");
        }
Example #7
0
        public void ConvertFrom_Case()
        {
            GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));

            Assert.AreEqual(FooEnum.Foo, cv.ConvertFrom(null, null, "foo"), "A1");
        }
Example #8
0
 public void Ctor_TypeError()
 {
     GenericEnumConverter cv = new GenericEnumConverter(typeof(object));
 }
Example #9
0
 public void Ctor_Null()
 {
     GenericEnumConverter cv = new GenericEnumConverter(null);
 }
Example #10
0
        public void ConvertTo_TypeError2()
        {
            GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));

            Assert.AreEqual("", cv.ConvertTo(null, null, "", typeof(string)), "A1");
        }
Example #11
0
        public void ConvertFrom_Case()
        {
            GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));

            AssertExtensions.Throws <ArgumentException>(null, () => cv.ConvertFrom(null, null, "foo"));
        }
Example #12
0
        public void ConvertTo_TypeError1()
        {
            GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));

            Assert.Equal("0", cv.ConvertTo(null, null, 0, typeof(string)));
        }
Example #13
0
        public void ConvertTo_NullError()
        {
            GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));

            Assert.Throws <NullReferenceException>(() => cv.ConvertTo(null, null, null, typeof(string)));
        }