1
- // Copyright (C) 2003-2010 Xtensive LLC.
2
- // All rights reserved .
3
- // For conditions of distribution and use, see license .
1
+ // Copyright (C) 2007-2022 Xtensive LLC.
2
+ // This code is distributed under MIT license terms .
3
+ // See the License.txt file in the project root for more information .
4
4
// Created by: Alex Yakunin
5
5
// Created: 2007.12.17
6
6
14
14
using Xtensive . Core ;
15
15
using Xtensive . Reflection ;
16
16
using Xtensive . Orm . Tests ;
17
+ using System . Linq ;
17
18
18
19
namespace Xtensive . Orm . Tests . Core . Reflection
19
20
{
@@ -480,5 +481,47 @@ public void GenericIsNullableTest()
480
481
Assert . IsFalse ( TypeHelper . IsNullable < int > ( ) ) ;
481
482
Assert . IsFalse ( TypeHelper . IsNullable < string > ( ) ) ;
482
483
}
484
+
485
+ [ Test ]
486
+ public void IsValueTupleTest ( )
487
+ {
488
+ var tupleTypes = new [ ] {
489
+ typeof ( ValueTuple < int > ) ,
490
+ typeof ( ValueTuple < int , int > ) ,
491
+ typeof ( ValueTuple < int , int , int > ) ,
492
+ typeof ( ValueTuple < int , int , int , int > ) ,
493
+ typeof ( ValueTuple < int , int , int , int , int > ) ,
494
+ typeof ( ValueTuple < int , int , int , int , int , int > ) ,
495
+ typeof ( ValueTuple < int , int , int , int , int , int , int > ) ,
496
+ typeof ( ValueTuple < int , int , int , int , int , int , int , int > )
497
+ } ;
498
+
499
+ var otherTypes = new [ ] {
500
+ typeof ( string ) ,
501
+ typeof ( char ) ,
502
+ typeof ( bool ) ,
503
+ typeof ( DateTime ) ,
504
+ typeof ( TimeSpan ) ,
505
+ typeof ( Guid ) ,
506
+ typeof ( TypeCode ) ,
507
+ typeof ( byte [ ] ) ,
508
+ typeof ( Key ) ,
509
+ this . GetType ( )
510
+ } ;
511
+
512
+ var startingToken = tupleTypes [ 0 ] . MetadataToken ;
513
+
514
+ Assert . That (
515
+ tupleTypes . Select ( t => t . MetadataToken - startingToken ) . SequenceEqual ( Enumerable . Range ( 0 , tupleTypes . Length ) ) ,
516
+ Is . True ) ;
517
+
518
+ foreach ( var type in tupleTypes ) {
519
+ Assert . IsTrue ( type . IsValueTuple ( ) ) ;
520
+ }
521
+
522
+ foreach ( var type in otherTypes ) {
523
+ Assert . IsFalse ( type . IsValueTuple ( ) ) ;
524
+ }
525
+ }
483
526
}
484
527
}
0 commit comments