Skip to content

Commit 138939c

Browse files
CSHARP-3078: Fix test CreateIndex_with_wildcardProjection_should_create_expected_index on latest
1 parent 69ac16f commit 138939c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ public void CreateIndex_with_wildcardProjection_should_create_expected_index()
7070
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
7171

7272
index["key"]["$**"].AsInt32.Should().Be(1);
73-
index["wildcardProjection"].Should().Be(BsonDocument.Parse("{ _id : 1 }"));
73+
if (CoreTestConfiguration.ServerVersion >= new SemanticVersion(4, 5, 0, ""))
74+
{
75+
index["wildcardProjection"].Should().Be(BsonDocument.Parse("{ _id : true }"));
76+
}
77+
else
78+
{
79+
index["wildcardProjection"].Should().Be(BsonDocument.Parse("{ _id : 1 }"));
80+
}
7481
}
7582

7683
[Fact]

tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTypedTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@ public void CreateIndex_with_wildcardProjection_should_create_expected_index()
8989
var indexes = collection.GetIndexes();
9090
var index = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
9191
index["key"]["$**"].AsInt32.Should().Be(1);
92-
index["wildcardProjection"].ToBsonDocument().Should().Be(BsonDocument.Parse("{ b : 1, _id : 0 }"));
92+
if (CoreTestConfiguration.ServerVersion >= new SemanticVersion(4, 5, 0, ""))
93+
{
94+
index["wildcardProjection"].Should().Be(BsonDocument.Parse("{ b : true, _id : false }"));
95+
}
96+
else
97+
{
98+
index["wildcardProjection"].Should().Be(BsonDocument.Parse("{ b : 1, _id : 0 }"));
99+
}
93100
}
94101

95102
[Fact]

0 commit comments

Comments
 (0)