public void RemoveConverterRemovesExistingConverter() { var target = new CustomConverterFactory(); Func<object, object> converter = x => null; target.RegisterConverter(typeof(CustomConverterFactoryTests), converter); var result1 = target.RemoveConverter(typeof (CustomConverterFactoryTests)); var result2 = target.GetConverter(typeof(CustomConverterFactoryTests)); Assert.IsNotNull(result1); Assert.AreSame(converter, result1); Assert.IsNull(result2); }
public void RemoveConverterThrowsArgumentNullExceptionIfTheTypeIsNull() { var target = new CustomConverterFactory(); var exception = Assert.Catch<ArgumentNullException>(() => target.RemoveConverter(null)); Assert.AreEqual("type", exception.ParamName); }
public void RemoveConverterRetunrsNullForNonRegisteredConverter() { var target = new CustomConverterFactory(); var result = target.RemoveConverter(typeof(CustomConverterFactoryTests)); Assert.IsNull(result); }
public void EnumConverterThrowsInvalidCastExceptionWhenCannotFindConverterForUnderlyingType() { var target = new CustomConverterFactory(); target.RemoveConverter(typeof(int)); // it's the underlying type for the HelloWorld enum var converter = target.GetConverter(typeof(HelloWorld)); Assert.Catch<InvalidCastException>(() => converter(2)); }