Performs conversion between values.
Exemple #1
0
        public void DoCanConverTest(Type fromType, Type toType, bool expected)
        {
            var target = new ValueConverter();

            bool result = target.CanConvert(fromType, toType);
            result.ShouldBe(expected);
        }
Exemple #2
0
 public void DoConvertTest(object value, object expected, Type expectedType)
 {
     var target = new ValueConverter();
     object actual = target.Convert(value, expectedType);
     actual.ShouldBe(expected);
 }
Exemple #3
0
 public void ConvertFailureTest()
 {
     var target = new ValueConverter();
     Should.Throw<InvalidOperationException>(() => target.Convert(null, typeof (int)));
 }
Exemple #4
0
 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);
 }
Exemple #5
0
 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);
 }
Exemple #6
0
 /// <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;
 }