Skip to content

Commit 8298824

Browse files
committed
CSHARP-5572: Fix test that was failing on older servers that don't support $filter with limit : 1
1 parent a0595b9 commit 8298824

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp5532Tests.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515

1616
using System.Collections.Generic;
1717
using System.Linq;
18+
using System.Text.RegularExpressions;
1819
using MongoDB.Driver.TestHelpers;
1920
using FluentAssertions;
2021
using MongoDB.Bson;
2122
using MongoDB.Bson.Serialization.Attributes;
23+
using MongoDB.Driver.Core.Misc;
2224
using Xunit;
2325

2426
namespace MongoDB.Driver.Tests.Linq.Linq3Implementation.Jira;
@@ -66,7 +68,7 @@ public void Projection_should_translate_correctly()
6668

6769
var projectionTranslation = TranslateFindProjection(collection, find);
6870

69-
projectionTranslation.Should().Be(
71+
var expectedTranslation =
7072
"""
7173
{
7274
_id :
@@ -132,7 +134,13 @@ public void Projection_should_translate_correctly()
132134
}
133135
}
134136
}
135-
""");
137+
""";
138+
if (!Feature.FilterLimit.IsSupported(CoreTestConfiguration.MaxWireVersion))
139+
{
140+
expectedTranslation = Regex.Replace(expectedTranslation, @",\s+limit : 1", "");
141+
}
142+
143+
projectionTranslation.Should().Be(expectedTranslation);
136144
}
137145

138146
public class Document

0 commit comments

Comments
 (0)