public void ConvertFrom_ValueIsNull_ThrowsNotSupportedException() { // Setup var converter = new NullableEnumConverter(typeof(SimpleEnum?)); // Call TestDelegate test = () => converter.ConvertFrom(null); // Assert Assert.Throws <NotSupportedException>(test); }
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); }
private T ConvertNullable <T>(T origin) { var redisVal = NullableEnumConverter.ConvertTo(origin, typeof(T), null); return((T)NullableEnumConverter.ConvertFrom(redisVal, typeof(T), null)); }