Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
0
        private T ConvertNullable <T>(T origin)
        {
            var redisVal = NullableEnumConverter.ConvertTo(origin, typeof(T), null);

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