예제 #1
0
        public void ConvertFrom_ValueIsNull_ThrowsNotSupportedException()
        {
            // Setup
            var converter = new NullableEnumConverter(typeof(SimpleEnum?));

            // Call
            TestDelegate test = () => converter.ConvertFrom(null);

            // Assert
            Assert.Throws <NotSupportedException>(test);
        }
예제 #2
0
        public void ConvertFrom_ValueIsString_ReturnsExpectedEnum()
        {
            // Setup
            const string second    = "<second>";
            var          converter = new NullableEnumConverter(typeof(SimpleEnum?));

            // Call
            object result = converter.ConvertFrom(second);

            // Assert
            const SimpleEnum expectedEnumValue = SimpleEnum.SecondValue;

            Assert.AreEqual(expectedEnumValue, result);
        }
예제 #3
0
        private T ConvertNullable <T>(T origin)
        {
            var redisVal = NullableEnumConverter.ConvertTo(origin, typeof(T), null);

            return((T)NullableEnumConverter.ConvertFrom(redisVal, typeof(T), null));
        }