44
55using System ;
66using System . Collections . Generic ;
7- using System . Diagnostics . CodeAnalysis ;
87using Microsoft . Toolkit . Extensions ;
98using Microsoft . VisualStudio . TestTools . UnitTesting ;
109
@@ -15,32 +14,33 @@ public class Test_TypeExtensions
1514 {
1615 [ TestCategory ( "TypeExtensions" ) ]
1716 [ TestMethod ]
18- public void Test_TypeExtensions_BuiltInTypes ( )
17+ [ DataRow ( "bool" , typeof ( bool ) ) ]
18+ [ DataRow ( "int" , typeof ( int ) ) ]
19+ [ DataRow ( "float" , typeof ( float ) ) ]
20+ [ DataRow ( "double" , typeof ( double ) ) ]
21+ [ DataRow ( "decimal" , typeof ( decimal ) ) ]
22+ [ DataRow ( "object" , typeof ( object ) ) ]
23+ [ DataRow ( "string" , typeof ( string ) ) ]
24+ public void Test_TypeExtensions_BuiltInTypes ( string name , Type type )
1925 {
20- Assert . AreEqual ( "bool" , typeof ( bool ) . ToTypeString ( ) ) ;
21- Assert . AreEqual ( "int" , typeof ( int ) . ToTypeString ( ) ) ;
22- Assert . AreEqual ( "float" , typeof ( float ) . ToTypeString ( ) ) ;
23- Assert . AreEqual ( "double" , typeof ( double ) . ToTypeString ( ) ) ;
24- Assert . AreEqual ( "decimal" , typeof ( decimal ) . ToTypeString ( ) ) ;
25- Assert . AreEqual ( "object" , typeof ( object ) . ToTypeString ( ) ) ;
26- Assert . AreEqual ( "string" , typeof ( string ) . ToTypeString ( ) ) ;
26+ Assert . AreEqual ( name , type . ToTypeString ( ) ) ;
2727 }
2828
2929 [ TestCategory ( "TypeExtensions" ) ]
3030 [ TestMethod ]
31- [ SuppressMessage ( "StyleCop.CSharp.SpacingRules" , "SA1009" , Justification = "Nullable value tuple type" ) ]
32- public void Test_TypeExtensions_GenericTypes ( )
31+ [ DataRow ( "int?" , typeof ( int ? ) ) ]
32+ [ DataRow ( "System.DateTime?" , typeof ( DateTime ? ) ) ]
33+ [ DataRow ( "(int, float)" , typeof ( ( int , float ) ) ) ]
34+ [ DataRow ( "(double?, string, int)?" , typeof ( ( double ? , string , int ) ? ) ) ]
35+ [ DataRow ( "int[]" , typeof ( int [ ] ) ) ]
36+ [ DataRow ( "int[,]" , typeof ( int [ , ] ) ) ]
37+ [ DataRow ( "System.Span<float>" , typeof ( Span < float > ) ) ]
38+ [ DataRow ( "System.Memory<char>" , typeof ( Memory < char > ) ) ]
39+ [ DataRow ( "System.Collections.Generic.IEnumerable<int>" , typeof ( IEnumerable < int > ) ) ]
40+ [ DataRow ( "System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<float>>" , typeof ( Dictionary < int , List < float > > ) ) ]
41+ public void Test_TypeExtensions_GenericTypes ( string name , Type type )
3342 {
34- Assert . AreEqual ( "int?" , typeof ( int ? ) . ToTypeString ( ) ) ;
35- Assert . AreEqual ( "System.DateTime?" , typeof ( DateTime ? ) . ToTypeString ( ) ) ;
36- Assert . AreEqual ( "(int, float)" , typeof ( ( int , float ) ) . ToTypeString ( ) ) ;
37- Assert . AreEqual ( "(double?, string, int)?" , typeof ( ( double ? , string , int ) ? ) . ToTypeString ( ) ) ;
38- Assert . AreEqual ( "int[]" , typeof ( int [ ] ) . ToTypeString ( ) ) ;
39- Assert . AreEqual ( typeof ( int [ , ] ) . ToTypeString ( ) , "int[,]" ) ;
40- Assert . AreEqual ( "System.Span<float>" , typeof ( Span < float > ) . ToTypeString ( ) ) ;
41- Assert . AreEqual ( "System.Memory<char>" , typeof ( Memory < char > ) . ToTypeString ( ) ) ;
42- Assert . AreEqual ( "System.Collections.Generic.IEnumerable<int>" , typeof ( IEnumerable < int > ) . ToTypeString ( ) ) ;
43- Assert . AreEqual ( typeof ( Dictionary < int , List < float > > ) . ToTypeString ( ) , "System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<float>>" ) ;
43+ Assert . AreEqual ( name , type . ToTypeString ( ) ) ;
4444 }
4545 }
4646}
0 commit comments