|
31 | 31 | using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
|
32 | 32 | using MongoDB.Driver.Core.Clusters;
|
33 | 33 | using MongoDB.Driver.Core.Misc;
|
| 34 | +using MongoDB.Driver.TestHelpers; |
| 35 | +using MongoDB.Driver.Core.Events; |
| 36 | +using MongoDB.Driver.Legacy.Tests; |
| 37 | +using MongoDB.Bson.TestHelpers; |
34 | 38 |
|
35 | 39 | namespace MongoDB.Driver.Tests
|
36 | 40 | {
|
@@ -423,6 +427,26 @@ public void TestCountZero()
|
423 | 427 | Assert.Equal(0, count);
|
424 | 428 | }
|
425 | 429 |
|
| 430 | + [SkippableFact] |
| 431 | + public void TestCountUsesImplicitSession() |
| 432 | + { |
| 433 | + RequireServer.Check(); |
| 434 | + |
| 435 | + var events = new EventCapturer().Capture<CommandStartedEvent>(x => x.CommandName == "count"); |
| 436 | + using (var client = DriverTestConfiguration.CreateDisposableClient(events)) |
| 437 | + { |
| 438 | + var server = client.GetServer(); |
| 439 | + var database = server.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName); |
| 440 | + var collection = database.GetCollection<BsonDocument>(DriverTestConfiguration.CollectionNamespace.CollectionName); |
| 441 | + collection.Count(); |
| 442 | + |
| 443 | + var commandStartedEvent = events.Next().Should().BeOfType<CommandStartedEvent>().Subject; |
| 444 | + var command = commandStartedEvent.Command; |
| 445 | + var areSessionsSupported = AreSessionsSupported(client); |
| 446 | + command.Contains("lsid").Should().Be(areSessionsSupported); |
| 447 | + } |
| 448 | + } |
| 449 | + |
426 | 450 | [Fact]
|
427 | 451 | public void TestCountOne()
|
428 | 452 | {
|
@@ -1227,7 +1251,7 @@ public void TestFindAndRemoveWithWriteConcernError()
|
1227 | 1251 | var collection = _database.GetCollection(_collection.Name, collectionSettings);
|
1228 | 1252 | var args = new FindAndRemoveArgs
|
1229 | 1253 | {
|
1230 |
| - Query = Query.EQ("x", 1) |
| 1254 | + Query = Query.EQ("x", 1) |
1231 | 1255 | };
|
1232 | 1256 |
|
1233 | 1257 | BsonDocument modifiedDocument;
|
@@ -3504,6 +3528,12 @@ public void TestWithWriteConcern()
|
3504 | 3528 | }
|
3505 | 3529 |
|
3506 | 3530 | // private methods
|
| 3531 | + private bool AreSessionsSupported(IMongoClient client) |
| 3532 | + { |
| 3533 | + var description = client.Cluster.Description; |
| 3534 | + return description.LogicalSessionTimeout.HasValue; |
| 3535 | + } |
| 3536 | + |
3507 | 3537 | private void CheckExpectedResult(ExpectedWriteConcernResult expectedResult, WriteConcernResult result)
|
3508 | 3538 | {
|
3509 | 3539 | Assert.Equal(expectedResult.DocumentsAffected ?? 0, result.DocumentsAffected);
|
|
0 commit comments