Convert() 개인적인 메소드

private Convert ( object sourceValue, Type targetType ) : object
sourceValue object
targetType System.Type
리턴 object
예제 #1
0
 public void DoConvertTest(object value, object expected, Type expectedType)
 {
     var target = new ValueConverter();
     object actual = target.Convert(value, expectedType);
     actual.ShouldBe(expected);
 }
예제 #2
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);
 }
예제 #3
0
 public void ConvertFailureTest()
 {
     var target = new ValueConverter();
     Should.Throw<InvalidOperationException>(() => target.Convert(null, typeof (int)));
 }
예제 #4
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);
 }