public void DoCanConverTest(Type fromType, Type toType, bool expected) { var target = new ValueConverter(); bool result = target.CanConvert(fromType, toType); result.ShouldBe(expected); }
public void DoConvertTest(object value, object expected, Type expectedType) { var target = new ValueConverter(); object actual = target.Convert(value, expectedType); actual.ShouldBe(expected); }
public void ConvertFailureTest() { var target = new ValueConverter(); Should.Throw<InvalidOperationException>(() => target.Convert(null, typeof (int))); }
public void DoConvert_NullableNull_ConvertsToNull(Type innerType) { var target = new ValueConverter(); Type genericNullableType = typeof (Nullable<>); Type concreteType = genericNullableType.MakeGenericType(innerType); object value = Activator.CreateInstance(concreteType); object actual = target.Convert(value, concreteType); actual.ShouldBe(null); }
public void DoConvert_NullableNotNull_ConvertsToNull() { var target = new ValueConverter(); DateTime? value = DateTime.Now; object actual = target.Convert(value, typeof (DateTime?)); actual.ShouldBe(value); actual.ShouldNotBeSameAs(value); }
/// <summary> /// Factory method targetMember create <see>ValueConverter</see> objects. /// </summary> /// <returns> /// A new instance of a <see>ValueConverter</see> object. /// </returns> protected virtual ValueConverter CreateValueConverter() { var typeChecker = new ValueConverter(); return typeChecker; }