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 .
44// Created by: Alex Yakunin
55// Created: 2007.12.17
66
1414using Xtensive . Core ;
1515using Xtensive . Reflection ;
1616using Xtensive . Orm . Tests ;
17+ using System . Linq ;
1718
1819namespace Xtensive . Orm . Tests . Core . Reflection
1920{
@@ -480,5 +481,47 @@ public void GenericIsNullableTest()
480481 Assert . IsFalse ( TypeHelper . IsNullable < int > ( ) ) ;
481482 Assert . IsFalse ( TypeHelper . IsNullable < string > ( ) ) ;
482483 }
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+ }
483526 }
484527}
0 commit comments