Esempio n. 1
0
        public void ConvertFromExcelTest()
        {
            var converter            = new EnumConverter(typeof(TestEnum));
            var typeConverterOptions = new TypeConverterOptions {
                CultureInfo = CultureInfo.CurrentCulture
            };

            Assert.AreEqual(TestEnum.One, converter.ConvertFromExcel(typeConverterOptions, "One"));
            Assert.AreEqual(TestEnum.One, converter.ConvertFromExcel(typeConverterOptions, "one"));
            Assert.AreEqual(TestEnum.One, converter.ConvertFromExcel(typeConverterOptions, "1"));
            try {
                Assert.AreEqual(TestEnum.One, converter.ConvertFromExcel(typeConverterOptions, ""));
                Assert.Fail();
            } catch (ExcelTypeConverterException) {
            }

            try {
                Assert.AreEqual(TestEnum.One, converter.ConvertFromExcel(typeConverterOptions, null));
                Assert.Fail();
            } catch (ExcelTypeConverterException) {
            }
        }