@@ -11,11 +11,26 @@ public class TypeConverterTests
1111 [ Theory ]
1212 [ InlineData ( 85 , typeof ( int ) , 85 ) ]
1313 [ InlineData ( "test" , typeof ( string ) , "test" ) ]
14- public void Test_SameType ( object value , Type targetType , object expectedValue )
14+ [ InlineData ( "test" , typeof ( object ) , "test" ) ]
15+ public void Test_NoConversion ( object value , Type targetType , object expectedValue )
1516 {
1617 TestConversion ( value , targetType , expectedValue ) ;
1718 }
1819
20+ [ Fact ]
21+ public void Test_NoSubClassConversion ( )
22+ {
23+ var b = new B ( ) ;
24+ TestConversion ( b , typeof ( A ) , b ) ;
25+ }
26+
27+ [ Fact ]
28+ public void Test_NoImplementedInterfaceConversion ( )
29+ {
30+ var a = new A ( ) ;
31+ TestConversion ( a , typeof ( ITest ) , a ) ;
32+ }
33+
1934 [ Theory ]
2035 [ InlineData ( 85 , typeof ( double ) , 85d ) ]
2136 [ InlineData ( 85 , typeof ( string ) , "85" ) ]
@@ -29,13 +44,13 @@ public void Test_SimpleConversion(object value, Type targetType, object expected
2944 [ Fact ]
3045 public void Test_ValueToNullable ( )
3146 {
32- TestConversion ( 100 , typeof ( int ? ) , ( int ? ) 100 ) ;
47+ TestConversion ( 100 , typeof ( int ? ) , ( int ? ) 100 ) ;
3348 }
3449
3550 [ Fact ]
3651 public void Test_NullableToValue ( )
3752 {
38- TestConversion ( ( int ? ) 100 , typeof ( int ) , 100 ) ;
53+ TestConversion ( ( int ? ) 100 , typeof ( int ) , 100 ) ;
3954 }
4055
4156 [ Fact ]
@@ -59,5 +74,16 @@ private static void TestConversion(object value, Type targetType, object expecte
5974 var result = DotNetTools . ConvertEx . ConvertEx . ChangeType ( value , targetType ) ;
6075 Assert . Equal ( expectedValue , result ) ;
6176 }
77+
78+ private class A : ITest
79+ {
80+
81+ }
82+
83+ private class B : A
84+ {
85+ }
86+
87+ private interface ITest { }
6288 }
6389}
0 commit comments