@@ -45,7 +45,7 @@ public void TypeHelper_IsCompatibleWith_SameTypes_True()
4545 }
4646
4747 [ Fact ]
48- public void TypeHelper_IsCompatibleWith_True ( )
48+ public void TypeHelper_IsCompatibleWith_Int_And_Long_Returns_True ( )
4949 {
5050 // Assign + Act
5151 var result = TypeHelper . IsCompatibleWith ( typeof ( int ) , typeof ( long ) ) ;
@@ -54,8 +54,52 @@ public void TypeHelper_IsCompatibleWith_True()
5454 Check . That ( result ) . IsTrue ( ) ;
5555 }
5656
57+ [ Theory ]
58+
59+ // True (enum underlying Int32 compatible targets)
60+ [ InlineData ( typeof ( DayOfWeek ) , true ) ]
61+ [ InlineData ( typeof ( DayOfWeek ? ) , true ) ]
62+ [ InlineData ( typeof ( int ) , true ) ]
63+ [ InlineData ( typeof ( int ? ) , true ) ]
64+ [ InlineData ( typeof ( long ) , true ) ]
65+ [ InlineData ( typeof ( long ? ) , true ) ]
66+ [ InlineData ( typeof ( float ) , true ) ]
67+ [ InlineData ( typeof ( float ? ) , true ) ]
68+ [ InlineData ( typeof ( double ) , true ) ]
69+ [ InlineData ( typeof ( double ? ) , true ) ]
70+ [ InlineData ( typeof ( decimal ) , true ) ]
71+ [ InlineData ( typeof ( decimal ? ) , true ) ]
72+ [ InlineData ( typeof ( object ) , true ) ]
73+
74+ // False (not compatible with enum's Int32 widening rules or reference types)
75+ [ InlineData ( typeof ( char ) , false ) ]
76+ [ InlineData ( typeof ( char ? ) , false ) ]
77+ [ InlineData ( typeof ( short ) , false ) ]
78+ [ InlineData ( typeof ( short ? ) , false ) ]
79+ [ InlineData ( typeof ( byte ) , false ) ]
80+ [ InlineData ( typeof ( byte ? ) , false ) ]
81+ [ InlineData ( typeof ( sbyte ) , false ) ]
82+ [ InlineData ( typeof ( sbyte ? ) , false ) ]
83+ [ InlineData ( typeof ( ushort ) , false ) ]
84+ [ InlineData ( typeof ( ushort ? ) , false ) ]
85+ [ InlineData ( typeof ( uint ) , false ) ]
86+ [ InlineData ( typeof ( uint ? ) , false ) ]
87+ [ InlineData ( typeof ( ulong ) , false ) ]
88+ [ InlineData ( typeof ( ulong ? ) , false ) ]
89+ [ InlineData ( typeof ( bool ) , false ) ]
90+ [ InlineData ( typeof ( bool ? ) , false ) ]
91+ [ InlineData ( typeof ( string ) , false ) ]
92+ public void TypeHelper_IsCompatibleWith_Enum ( Type targetType , bool expected )
93+ {
94+ // Assign + Act
95+ var result = TypeHelper . IsCompatibleWith ( typeof ( DayOfWeek ) , targetType ) ;
96+
97+ // Assert
98+ result . Should ( ) . Be ( expected ) ;
99+ }
100+
57101 [ Fact ]
58- public void TypeHelper_IsCompatibleWith_False ( )
102+ public void TypeHelper_IsCompatibleWith_Long_And_Int_Returns_False ( )
59103 {
60104 // Assign + Act
61105 var result = TypeHelper . IsCompatibleWith ( typeof ( long ) , typeof ( int ) ) ;
0 commit comments