private static void VerifySessionAndCancellationToken <TDocument>(MockOperationExecutor.WriteCall <TDocument> call, IClientSessionHandle session, CancellationToken cancellationToken) { call.CancellationToken.Should().Be(cancellationToken); if (session == null) { call.UsedImplicitSession.Should().BeTrue(); } else { call.SessionId.Should().Be(session.ServerSession.Id); } }
private static void VerifySingleWrite <TRequest>(TRequest expectedRequest, MockOperationExecutor.WriteCall <BulkWriteOperationResult> call) { call.Operation.Should().BeOfType <BulkMixedWriteOperation>(); var operation = (BulkMixedWriteOperation)call.Operation; operation.CollectionNamespace.FullName.Should().Be("foo.bar"); operation.IsOrdered.Should().BeTrue(); operation.Requests.Count().Should().Be(1); operation.Requests.Single().Should().BeOfType <TRequest>(); operation.Requests.Single().ShouldBeEquivalentTo(expectedRequest); }
private static void VerifySingleWrite <TRequest>(TRequest expectedRequest, MockOperationExecutor.WriteCall <BulkWriteOperationResult> call) where TRequest : WriteRequest { VerifyWrites(new[] { expectedRequest }, true, call); }
private static void VerifyWrites(WriteRequest[] expectedRequests, bool isOrdered, MockOperationExecutor.WriteCall <BulkWriteOperationResult> call) { call.Operation.Should().BeOfType <BulkMixedWriteOperation>(); var operation = (BulkMixedWriteOperation)call.Operation; operation.CollectionNamespace.FullName.Should().Be("foo.bar"); operation.IsOrdered.Should().Be(isOrdered); var actualRequests = operation.Requests.ToList(); actualRequests.Count.Should().Be(expectedRequests.Length); for (int i = 0; i < expectedRequests.Length; i++) { expectedRequests[i].ShouldBeEquivalentTo(actualRequests[i]); } }