Example #1
0
        public void Test_Int_Enum_Dynamic()
        {
            Assert.AreEqual(TestEnum.One, int1.Convert(typeof(TestEnum)));
            Assert.AreEqual(TestEnum.One, intN1.Convert(typeof(TestEnum)));
            Assert.AreEqual(1, enum1.Convert(typeof(int)));
            Assert.AreEqual(1, enumN1.Convert(typeof(int)));

            Assert.AreEqual(TestEnum.Two, int2.Convert(typeof(TestEnum)));
            Assert.AreEqual(TestEnum.Two, intN2.Convert(typeof(TestEnum)));
            Assert.AreEqual(2, enum2.Convert(typeof(int)));
            Assert.AreEqual(2, enumN2.Convert(typeof(int)));

            Assert.AreEqual(enumDefault, int99.Convert(typeof(TestEnum)));
            Assert.AreEqual(enumDefault, intN99.Convert(typeof(TestEnum)));

            Assert.AreEqual(TestEnum.One, int1.Convert(typeof(TestEnum?)));
            Assert.AreEqual(1, enum1.Convert(typeof(int?)));

            Assert.AreEqual(TestEnum.Two, int2.Convert(typeof(TestEnum?)));
            Assert.AreEqual(2, enum2.Convert(typeof(int?)));

            Assert.AreEqual(null, int99.Convert(typeof(TestEnum?)));
        }