Skip to content

Commit ae161bc

Browse files
rstamBorisDog
authored andcommitted
CSHARP-4100: Skip tests that fail on .NET Core 2.1 due to bugs in .NET Core 2.1.
1 parent b98fc43 commit ae161bc

File tree

2 files changed

+68
-4
lines changed

2 files changed

+68
-4
lines changed

tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4100ExpressionTests.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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; }

tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4100FilterTests.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ public void Contains_with_string_field_and_string_constant_and_comparisonType_sh
301301
#if !NETFRAMEWORK
302302
[Theory]
303303
[InlineData(StringComparison.CurrentCulture, "{ $match : { _id : { $type : -1 } } }")]
304+
#if !NETCOREAPP2_1
305+
// there are bugs related to case insensitive string comparisons in .NET Core 2.1
306+
// https://github.com/dotnet/runtime/issues/27376
304307
[InlineData(StringComparison.CurrentCultureIgnoreCase, "{ $match : { } }")]
308+
#endif
305309
public void Contains_with_string_constant_and_string_constant_and_comparisonType_should_work(StringComparison comparisonType, string expectedStage)
306310
{
307311
var collection = GetCollection<Test>();
@@ -533,7 +537,11 @@ public void EndsWith_with_string_field_and_string_constant_and_ignoreCase_and_cu
533537

534538
[Theory]
535539
[InlineData(false, "{ $match : { _id : { $type : -1 } } }")]
540+
#if !NETCOREAPP2_1
541+
// there are bugs related to case insensitive string comparisons in .NET Core 2.1
542+
// https://github.com/dotnet/runtime/issues/27376
536543
[InlineData(true, "{ $match : { } }")]
544+
#endif
537545
public void EndsWith_with_string_constant_and_string_constant_and_ignoreCase_and_culture_should_work(bool ignoreCase, string expectedStage)
538546
{
539547
var collection = GetCollection<Test>();
@@ -579,8 +587,9 @@ public void EndsWith_with_string_constant_and_string_field_and_ignoreCase_and_cu
579587
public void EndsWith_with_string_field_and_string_value_and_ignoreCase_and_invalid_culture_should_throw(bool ignoreCase)
580588
{
581589
var collection = GetCollection<Test>();
590+
var notCurrentCulture = GetACultureThatIsNotTheCurrentCulture();
582591
var queryable = collection.AsQueryable()
583-
.Where(x => x.S.EndsWith("aBc", ignoreCase, CultureInfo.InvariantCulture));
592+
.Where(x => x.S.EndsWith("aBc", ignoreCase, notCurrentCulture));
584593

585594
var exception = Record.Exception(() => Translate(collection, queryable));
586595

@@ -618,7 +627,11 @@ public void EndsWith_with_string_field_and_string_constant_and_comparisonType_sh
618627

619628
[Theory]
620629
[InlineData(StringComparison.CurrentCulture, "{ $match : { _id : { $type : -1 } } }")]
630+
#if !NETCOREAPP2_1
631+
// there are bugs related to case insensitive string comparisons in .NET Core 2.1
632+
// https://github.com/dotnet/runtime/issues/27376
621633
[InlineData(StringComparison.CurrentCultureIgnoreCase, "{ $match : { } }")]
634+
#endif
622635
public void EndsWith_with_string_constant_and_string_constant_and_comparisonType_should_work(StringComparison comparisonType, string expectedStage)
623636
{
624637
var collection = GetCollection<Test>();
@@ -842,7 +855,11 @@ public void StartsWith_with_string_field_and_string_constant_and_ignoreCase_and_
842855

843856
[Theory]
844857
[InlineData(false, "{ $match : { _id : { $type : -1 } } }")]
858+
#if !NETCOREAPP2_1
859+
// there are bugs related to case insensitive string comparisons in .NET Core 2.1
860+
// https://github.com/dotnet/runtime/issues/27376
845861
[InlineData(true, "{ $match : { } }")]
862+
#endif
846863
public void StartsWith_with_string_constant_and_string_constant_and_ignoreCase_and_culture_should_work(bool ignoreCase, string expectedStage)
847864
{
848865
var collection = GetCollection<Test>();
@@ -888,8 +905,9 @@ public void StartsWith_with_string_constant_and_string_field_and_ignoreCase_and_
888905
public void StartsWith_with_string_field_and_string_value_and_ignoreCase_and_invalid_culture_should_throw(bool ignoreCase)
889906
{
890907
var collection = GetCollection<Test>();
908+
var notCurrentCulture = GetACultureThatIsNotTheCurrentCulture();
891909
var queryable = collection.AsQueryable()
892-
.Where(x => x.S.StartsWith("aBc", ignoreCase, CultureInfo.InvariantCulture));
910+
.Where(x => x.S.StartsWith("aBc", ignoreCase, notCurrentCulture));
893911

894912
var exception = Record.Exception(() => Translate(collection, queryable));
895913

@@ -927,7 +945,11 @@ public void StartsWith_with_string_field_and_string_constant_and_comparisonType_
927945

928946
[Theory]
929947
[InlineData(StringComparison.CurrentCulture, "{ $match : { _id : { $type : -1 } } }")]
948+
#if !NETCOREAPP2_1
949+
// there are bugs related to case insensitive string comparisons in .NET Core 2.1
950+
// https://github.com/dotnet/runtime/issues/27376
930951
[InlineData(StringComparison.CurrentCultureIgnoreCase, "{ $match : { } }")]
952+
#endif
931953
public void StartsWith_with_string_constant_and_string_constant_and_comparisonType_should_work(StringComparison comparisonType, string expectedStage)
932954
{
933955
var collection = GetCollection<Test>();
@@ -1001,6 +1023,16 @@ public void StartsWith_with_string_constant_and_string_value_and_invalid_compari
10011023
exception.Message.Should().Contain($"{comparisonType} is not supported");
10021024
}
10031025

1026+
private CultureInfo GetACultureThatIsNotTheCurrentCulture()
1027+
{
1028+
var notCurrentCulture = CultureInfo.GetCultureInfo("zu-ZA");
1029+
if (notCurrentCulture.Equals(CultureInfo.CurrentCulture))
1030+
{
1031+
notCurrentCulture = CultureInfo.GetCultureInfo("yo-NG");
1032+
}
1033+
return notCurrentCulture;
1034+
}
1035+
10041036
public class Test
10051037
{
10061038
public char CC { get; set; }

0 commit comments

Comments
 (0)