@@ -302,7 +302,11 @@ public void Contains_with_string_field_and_string_constant_and_comparisonType_sh
302302#if ! NETFRAMEWORK
303303 [ Theory ]
304304 [ 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
305308 [ InlineData ( StringComparison . CurrentCultureIgnoreCase , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
309+ #endif
306310 public void Contains_with_string_constant_and_string_constant_and_comparisonType_should_work ( StringComparison comparisonType , string expectedStage )
307311 {
308312 var collection = GetCollection < Test > ( ) ;
@@ -534,7 +538,11 @@ public void EndsWith_with_string_field_and_string_constant_and_ignoreCase_and_cu
534538
535539 [ Theory ]
536540 [ 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
537544 [ InlineData ( true , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
545+ #endif
538546 public void EndsWith_with_string_constant_and_string_constant_and_ignoreCase_and_culture_should_work ( bool ignoreCase , string expectedStage )
539547 {
540548 var collection = GetCollection < Test > ( ) ;
@@ -580,8 +588,9 @@ public void EndsWith_with_string_constant_and_string_field_and_ignoreCase_and_cu
580588 public void EndsWith_with_string_field_and_string_value_and_ignoreCase_and_invalid_culture_should_throw ( bool ignoreCase )
581589 {
582590 var collection = GetCollection < Test > ( ) ;
591+ var notCurrentCulture = GetACultureThatIsNotTheCurrentCulture ( ) ;
583592 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 ) } ) ;
585594
586595 var exception = Record . Exception ( ( ) => Translate ( collection , queryable ) ) ;
587596
@@ -619,7 +628,11 @@ public void EndsWith_with_string_field_and_string_constant_and_comparisonType_sh
619628
620629 [ Theory ]
621630 [ 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
622634 [ InlineData ( StringComparison . CurrentCultureIgnoreCase , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
635+ #endif
623636 public void EndsWith_with_string_constant_and_string_constant_and_comparisonType_should_work ( StringComparison comparisonType , string expectedStage )
624637 {
625638 var collection = GetCollection < Test > ( ) ;
@@ -843,7 +856,11 @@ public void StartsWith_with_string_field_and_string_constant_and_ignoreCase_and_
843856
844857 [ Theory ]
845858 [ 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
846862 [ InlineData ( true , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
863+ #endif
847864 public void StartsWith_with_string_constant_and_string_constant_and_ignoreCase_and_culture_should_work ( bool ignoreCase , string expectedStage )
848865 {
849866 var collection = GetCollection < Test > ( ) ;
@@ -889,8 +906,9 @@ public void StartsWith_with_string_constant_and_string_field_and_ignoreCase_and_
889906 public void StartsWith_with_string_field_and_string_value_and_ignoreCase_and_invalid_culture_should_throw ( bool ignoreCase )
890907 {
891908 var collection = GetCollection < Test > ( ) ;
909+ var notCurrentCulture = GetACultureThatIsNotTheCurrentCulture ( ) ;
892910 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 ) } ) ;
894912
895913 var exception = Record . Exception ( ( ) => Translate ( collection , queryable ) ) ;
896914
@@ -928,7 +946,11 @@ public void StartsWith_with_string_field_and_string_constant_and_comparisonType_
928946
929947 [ Theory ]
930948 [ 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
931952 [ InlineData ( StringComparison . CurrentCultureIgnoreCase , "{ $project : { _v : { R : true }, _id : 0 } }" ) ]
953+ #endif
932954 public void StartsWith_with_string_constant_and_string_constant_and_comparisonType_should_work ( StringComparison comparisonType , string expectedStage )
933955 {
934956 var collection = GetCollection < Test > ( ) ;
@@ -1002,6 +1024,16 @@ public void StartsWith_with_string_constant_and_string_value_and_invalid_compari
10021024 exception . Message . Should ( ) . Contain ( $ "{ comparisonType } is not supported") ;
10031025 }
10041026
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+
10051037 public class Test
10061038 {
10071039 public char CC { get ; set ; }
0 commit comments