@@ -302,7 +302,11 @@ public void Contains_with_string_field_and_string_constant_and_comparisonType_sh
302
302
#if ! NETFRAMEWORK
303
303
[ Theory ]
304
304
[ InlineData ( StringComparison . CurrentCulture , "{ $project : { _v : { R : false }, _id : 0 } }" ) ]
305
+ #if ! NETCOREAPP2_1
306
+ // there are bugs related to case insensitive string comparisons in .NET Core 2.1
307
+ // https://github.com/dotnet/runtime/issues/27376
305
308
[ InlineData ( StringComparison . CurrentCultureIgnoreCase , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
309
+ #endif
306
310
public void Contains_with_string_constant_and_string_constant_and_comparisonType_should_work ( StringComparison comparisonType , string expectedStage )
307
311
{
308
312
var collection = GetCollection < Test > ( ) ;
@@ -534,7 +538,11 @@ public void EndsWith_with_string_field_and_string_constant_and_ignoreCase_and_cu
534
538
535
539
[ Theory ]
536
540
[ InlineData ( false , "{ $project : { _v : { R : false }, _id : 0 } }" ) ]
541
+ #if ! NETCOREAPP2_1
542
+ // there are bugs related to case insensitive string comparisons in .NET Core 2.1
543
+ // https://github.com/dotnet/runtime/issues/27376
537
544
[ InlineData ( true , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
545
+ #endif
538
546
public void EndsWith_with_string_constant_and_string_constant_and_ignoreCase_and_culture_should_work ( bool ignoreCase , string expectedStage )
539
547
{
540
548
var collection = GetCollection < Test > ( ) ;
@@ -580,8 +588,9 @@ public void EndsWith_with_string_constant_and_string_field_and_ignoreCase_and_cu
580
588
public void EndsWith_with_string_field_and_string_value_and_ignoreCase_and_invalid_culture_should_throw ( bool ignoreCase )
581
589
{
582
590
var collection = GetCollection < Test > ( ) ;
591
+ var notCurrentCulture = GetACultureThatIsNotTheCurrentCulture ( ) ;
583
592
var queryable = collection . AsQueryable ( )
584
- . Select ( x => new { R = x . S . EndsWith ( "aBc" , ignoreCase , CultureInfo . InvariantCulture ) } ) ;
593
+ . Select ( x => new { R = x . S . EndsWith ( "aBc" , ignoreCase , notCurrentCulture ) } ) ;
585
594
586
595
var exception = Record . Exception ( ( ) => Translate ( collection , queryable ) ) ;
587
596
@@ -619,7 +628,11 @@ public void EndsWith_with_string_field_and_string_constant_and_comparisonType_sh
619
628
620
629
[ Theory ]
621
630
[ InlineData ( StringComparison . CurrentCulture , "{ $project : { _v : { R : false }, _id : 0 } }" ) ]
631
+ #if ! NETCOREAPP2_1
632
+ // there are bugs related to case insensitive string comparisons in .NET Core 2.1
633
+ // https://github.com/dotnet/runtime/issues/27376
622
634
[ InlineData ( StringComparison . CurrentCultureIgnoreCase , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
635
+ #endif
623
636
public void EndsWith_with_string_constant_and_string_constant_and_comparisonType_should_work ( StringComparison comparisonType , string expectedStage )
624
637
{
625
638
var collection = GetCollection < Test > ( ) ;
@@ -843,7 +856,11 @@ public void StartsWith_with_string_field_and_string_constant_and_ignoreCase_and_
843
856
844
857
[ Theory ]
845
858
[ InlineData ( false , "{ $project : { _v : { R : false }, _id : 0 } }" ) ]
859
+ #if ! NETCOREAPP2_1
860
+ // there are bugs related to case insensitive string comparisons in .NET Core 2.1
861
+ // https://github.com/dotnet/runtime/issues/27376
846
862
[ InlineData ( true , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
863
+ #endif
847
864
public void StartsWith_with_string_constant_and_string_constant_and_ignoreCase_and_culture_should_work ( bool ignoreCase , string expectedStage )
848
865
{
849
866
var collection = GetCollection < Test > ( ) ;
@@ -889,8 +906,9 @@ public void StartsWith_with_string_constant_and_string_field_and_ignoreCase_and_
889
906
public void StartsWith_with_string_field_and_string_value_and_ignoreCase_and_invalid_culture_should_throw ( bool ignoreCase )
890
907
{
891
908
var collection = GetCollection < Test > ( ) ;
909
+ var notCurrentCulture = GetACultureThatIsNotTheCurrentCulture ( ) ;
892
910
var queryable = collection . AsQueryable ( )
893
- . Select ( x => new { R = x . S . StartsWith ( "aBc" , ignoreCase , CultureInfo . InvariantCulture ) } ) ;
911
+ . Select ( x => new { R = x . S . StartsWith ( "aBc" , ignoreCase , notCurrentCulture ) } ) ;
894
912
895
913
var exception = Record . Exception ( ( ) => Translate ( collection , queryable ) ) ;
896
914
@@ -928,7 +946,11 @@ public void StartsWith_with_string_field_and_string_constant_and_comparisonType_
928
946
929
947
[ Theory ]
930
948
[ InlineData ( StringComparison . CurrentCulture , "{ $project : { _v : { R : false }, _id : 0 } }" ) ]
949
+ #if ! NETCOREAPP2_1
950
+ // there are bugs related to case insensitive string comparisons in .NET Core 2.1
951
+ // https://github.com/dotnet/runtime/issues/27376
931
952
[ InlineData ( StringComparison . CurrentCultureIgnoreCase , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
953
+ #endif
932
954
public void StartsWith_with_string_constant_and_string_constant_and_comparisonType_should_work ( StringComparison comparisonType , string expectedStage )
933
955
{
934
956
var collection = GetCollection < Test > ( ) ;
@@ -1002,6 +1024,16 @@ public void StartsWith_with_string_constant_and_string_value_and_invalid_compari
1002
1024
exception . Message . Should ( ) . Contain ( $ "{ comparisonType } is not supported") ;
1003
1025
}
1004
1026
1027
+ private CultureInfo GetACultureThatIsNotTheCurrentCulture ( )
1028
+ {
1029
+ var notCurrentCulture = CultureInfo . GetCultureInfo ( "zu-ZA" ) ;
1030
+ if ( notCurrentCulture . Equals ( CultureInfo . CurrentCulture ) )
1031
+ {
1032
+ notCurrentCulture = CultureInfo . GetCultureInfo ( "yo-NG" ) ;
1033
+ }
1034
+ return notCurrentCulture ;
1035
+ }
1036
+
1005
1037
public class Test
1006
1038
{
1007
1039
public char CC { get ; set ; }
0 commit comments