public void CreateCommand_should_return_the_expected_result(
            [Values(false, true)]
            bool useServerVersionSupportingAggregateCursorResult)
        {
            var subject       = new AggregateOperation <BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings);
            var serverVersion = Feature.AggregateCursorResult.SupportedOrNotSupportedVersion(useServerVersionSupportingAggregateCursorResult);

            var connectionDescription = OperationTestHelper.CreateConnectionDescription(serverVersion);
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "aggregate", _collectionNamespace.CollectionName },
                { "pipeline", new BsonArray(__pipeline) },
                { "cursor", () => new BsonDocument(), Feature.AggregateCursorResult.IsSupported(serverVersion) }
            };

            result.Should().Be(expectedResult);
        }
Example #2
0
        public void CreateCommand_should_return_expected_result_when_UsePowerOf2Sizes_is_set(
            [Values(null, false, true)]
            bool?usePowerOf2Sizes)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                UsePowerOf2Sizes = usePowerOf2Sizes
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "flags", () => usePowerOf2Sizes.Value ? 1 : 0, usePowerOf2Sizes != null }
            };

            result.Should().Be(expectedResult);
        }
Example #3
0
        public void CreateCommand_should_return_expected_result_when_ValidationLevel_is_set(
            [Values(null, DocumentValidationLevel.Moderate, DocumentValidationLevel.Off)]
            DocumentValidationLevel?validationLevel)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                ValidationLevel = validationLevel
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "validationLevel", () => validationLevel.ToString().ToLowerInvariant(), validationLevel != null }
            };

            result.Should().Be(expectedResult);
        }
Example #4
0
        public void CreateCommand_should_return_expected_result_when_NoPadding_is_set(
            [Values(null, false, true)]
            bool?noPadding)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                NoPadding = noPadding
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "flags", () => noPadding.Value ? 2 : 0, noPadding != null }
            };

            result.Should().Be(expectedResult);
        }
Example #5
0
        public void CreateCommand_should_return_expected_result_when_MaxSize_is_set(
            [Values(null, 1L, 2L)]
            long?maxSize)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                MaxSize = maxSize
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "size", () => maxSize.Value, maxSize != null }
            };

            result.Should().Be(expectedResult);
        }
Example #6
0
        public void CreateCommand_should_return_expected_result_when_Capped_is_set(
            [Values(null, false, true)]
            bool?capped)
        {
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Capped = capped
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "capped", () => capped.Value, capped != null }
            };

            result.Should().Be(expectedResult);
        }
        public void CreateCommand_should_return_expected_result_when_WriteConcern_is_set(
            [Values(null, 1, 2)]
            int?w)
        {
            var writeConcern = w.HasValue ? new WriteConcern(w.Value) : null;
            var subject      = new DropCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                WriteConcern = writeConcern
            };
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(session);

            var expectedResult = new BsonDocument
            {
                { "drop", _collectionNamespace.CollectionName },
                { "writeConcern", () => writeConcern.ToBsonDocument(), writeConcern != null }
            };

            result.Should().Be(expectedResult);
        }
        public void ReadConcern_document_should_contain_the_expected_values(
            [Values(false, true)] bool supportsSessions,
            [Values(false, true)] bool causallyConsistent,
            [Values(null, 10L)] long?operationTime,
            [Values(null, ReadConcernLevel.Majority)] ReadConcernLevel?level)
        {
            var           connectionDescription = OperationTestHelper.CreateConnectionDescription(supportsSessions: supportsSessions);
            BsonTimestamp timestamp             = operationTime == null ? null : new BsonTimestamp(operationTime.Value);
            var           session = OperationTestHelper.CreateSession(causallyConsistent, timestamp);

            var readConcern = ReadConcern.Default;

            if (level != null)
            {
                readConcern = readConcern.With(level.Value);
            }

            var command = new BsonDocument();

            ReadConcernHelper.AppendReadConcern(command, readConcern, connectionDescription, session);

            if ((!supportsSessions || !causallyConsistent || operationTime == null) && level == null)
            {
                command.ElementCount.Should().Be(0);
            }
            else
            {
                command.Contains("readConcern").Should().BeTrue();
            }

            if (level != null)
            {
                command["readConcern"]["level"].AsString.Should().Be("majority");
            }

            if (supportsSessions && causallyConsistent && operationTime != null)
            {
                command["readConcern"]["afterClusterTime"].AsBsonTimestamp.Value.Should().Be(operationTime.Value);
            }
        }
        public void CreateCommand_should_create_the_correct_command(
            [Values(WireVersion.Server30, WireVersion.Server32)] int maxWireVersion,
            [Values(null, ReadConcernLevel.Local, ReadConcernLevel.Majority)] ReadConcernLevel?readConcernLevel)
        {
            var filter      = new BsonDocument("x", 1);
            var limit       = 10;
            var maxDistance = 30;
            var maxTime     = TimeSpan.FromMilliseconds(50);
            var near        = new BsonArray {
                10, 20
            };
            var readConcern = new ReadConcern(readConcernLevel);
            var subject     = new GeoSearchOperation <BsonDocument>(_collectionNamespace, near, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                Search      = filter,
                Limit       = limit,
                MaxDistance = maxDistance,
                MaxTime     = maxTime,
                ReadConcern = readConcern
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription(maxWireVersion);
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "geoSearch", _collectionNamespace.CollectionName },
                { "near", near },
                { "limit", limit },
                { "maxDistance", maxDistance },
                { "search", filter },
                { "maxTimeMS", (int)maxTime.TotalMilliseconds },
                { "readConcern", () => readConcern.ToBsonDocument(), !readConcern.IsServerDefault }
            };

            result.Should().Be(expectedResult);
            result["maxTimeMS"].BsonType.Should().Be(BsonType.Int32);
        }
        public void CreateCommand_should_return_expected_result_when_Skip_is_set(
            [Values(null, 1L, 2L)]
            long?skip)
        {
            var subject = new CountOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Skip = skip
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription();
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "count", _collectionNamespace.CollectionName },
                { "skip", () => skip.Value, skip != null }
            };

            result.Should().Be(expectedResult);
        }
        public void CreateCommand_should_return_expected_result_when_Validator_is_set(
            [Values(null, "{ x : 1 }", "{ x : 2 }")]
            string validatorString)
        {
            var validator = validatorString == null ? null : BsonDocument.Parse(validatorString);
            var subject   = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Validator = validator
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "validator", validator, validator != null }
            };

            result.Should().Be(expectedResult);
        }
        public void CreateCommand_should_return_expected_result_when_IndexOptionDefaults_is_set(
            [Values(null, "{ x : 1 }", "{ x : 2 }")]
            string indexOptionDefaultsString)
        {
            var indexOptionDefaults = indexOptionDefaultsString == null ? null : BsonDocument.Parse(indexOptionDefaultsString);
            var subject             = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                IndexOptionDefaults = indexOptionDefaults
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "indexOptionDefaults", () => indexOptionDefaults, indexOptionDefaults != null }
            };

            result.Should().Be(expectedResult);
        }
        public void CreateCommand_should_return_expected_result_when_Collation_is_set(
            [Values(null, "en_US", "fr_CA")]
            string locale)
        {
            var collation = locale == null ? null : new Collation(locale);
            var subject   = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                Collation = collation
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription(serverVersion: Feature.Collation.FirstSupportedVersion);

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "collation", () => collation.ToBsonDocument(), collation != null }
            };

            result.Should().Be(expectedResult);
        }
Example #14
0
        public void CreateCommand_should_include_readConcern_when_using_causal_consistency(
            [Values(null, ReadConcernLevel.Local, ReadConcernLevel.Majority)] ReadConcernLevel?readConcernLevel)
        {
            var readConcern    = new ReadConcern(readConcernLevel);
            var mapFunction    = "function() { emit(this.x, this.v); }";
            var reduceFunction = "function(key, values) { var sum = 0; for (var i = 0; i < values.length; i++) { sum += values[i]; }; return sum; }";
            var subject        = new MapReduceLegacyOperation(_collectionNamespace, mapFunction, reduceFunction, _messageEncoderSettings)
            {
                ReadConcern = readConcern
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription(Feature.ReadConcern.FirstSupportedVersion, supportsSessions: true);
            var session = OperationTestHelper.CreateSession(true, new BsonTimestamp(100));

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedReadConcernDocument = readConcern.ToBsonDocument();

            expectedReadConcernDocument["afterClusterTime"] = new BsonTimestamp(100);

            result["readConcern"].Should().Be(expectedReadConcernDocument);
        }
        public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long maxTimeTicks, int expectedMaxTimeMS)
        {
            var subject = new DistinctOperation <int>(_collectionNamespace, _valueSerializer, _fieldName, _messageEncoderSettings)
            {
                MaxTime = TimeSpan.FromTicks(maxTimeTicks)
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription();
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "distinct", _collectionNamespace.CollectionName },
                { "key", _fieldName },
                { "maxTimeMS", expectedMaxTimeMS }
            };

            result.Should().Be(expectedResult);
            result["maxTimeMS"].BsonType.Should().Be(BsonType.Int32);
        }
        public void CreateCommand_should_return_expected_result_when_WriteConcern_is_set(
            [Values(null, 1, 2)]
            int?w)
        {
            var writeConcern = w.HasValue ? new WriteConcern(w.Value) : null;
            var subject      = new DropDatabaseOperation(_databaseNamespace, _messageEncoderSettings)
            {
                WriteConcern = writeConcern
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription(serverVersion: Feature.CommandsThatWriteAcceptWriteConcern.FirstSupportedVersion);

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "dropDatabase", 1 },
                { "writeConcern", () => writeConcern.ToBsonDocument(), writeConcern != null }
            };

            result.Should().Be(expectedResult);
        }
Example #17
0
        public void CreateCommand_should_return_expected_result_when_AutoIndexId_is_set(
            [Values(null, false, true)]
            bool?autoIndexId)
        {
#pragma warning disable 618
            var subject = new CreateCollectionOperation(_collectionNamespace, _messageEncoderSettings)
            {
                AutoIndexId = autoIndexId
            };
#pragma warning restore
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "create", _collectionNamespace.CollectionName },
                { "autoIndexId", () => autoIndexId.Value, autoIndexId != null }
            };
            result.Should().Be(expectedResult);
        }
        public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long maxTimeTicks, int expectedMaxTimeMS)
        {
            var subject = new AggregateOperation <BsonDocument>(_collectionNamespace, __pipeline, __resultSerializer, _messageEncoderSettings)
            {
                MaxTime = TimeSpan.FromTicks(maxTimeTicks)
            };
            var connectionDescription = OperationTestHelper.CreateConnectionDescription(Feature.AggregateCursorResult.FirstSupportedVersion);
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "aggregate", _collectionNamespace.CollectionName },
                { "pipeline", new BsonArray(__pipeline) },
                { "maxTimeMS", expectedMaxTimeMS },
                { "cursor", new BsonDocument() }
            };

            result.Should().Be(expectedResult);
            result["maxTimeMS"].BsonType.Should().Be(BsonType.Int32);
        }
Example #19
0
        public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long maxTimeTicks, int expectedMaxTimeMS)
        {
            var near    = 5;
            var subject = new GeoSearchOperation <BsonDocument>(_collectionNamespace, near, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                MaxTime = TimeSpan.FromTicks(maxTimeTicks)
            };
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "geoSearch", _collectionNamespace.CollectionName },
                { "near", near },
                { "maxTimeMS", expectedMaxTimeMS }
            };

            result.Should().Be(expectedResult);
            result["maxTimeMS"].BsonType.Should().Be(BsonType.Int32);
        }
Example #20
0
        public void CreateCommand_should_return_expected_result_when_Snapshot_is_set(
            [Values(null, false, true)]
            bool?snapshot)
        {
            var subject = new FindCommandOperation <BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                Snapshot = snapshot
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription();
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "find", _collectionNamespace.CollectionName },
                { "snapshot", () => snapshot.Value, snapshot.HasValue }
            };

            result.Should().Be(expectedResult);
        }
Example #21
0
        public void CreateCommand_should_return_expected_result_when_Comment_is_set(
            [Values(null, "a", "b")]
            string comment)
        {
            var subject = new FindCommandOperation <BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                Comment = comment
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription();
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "find", _collectionNamespace.CollectionName },
                { "comment", () => comment, comment != null }
            };

            result.Should().Be(expectedResult);
        }
Example #22
0
        public void CreateCommand_should_return_expected_result_when_Skip_is_set(
            [Values(null, 0, 1, 2)]
            int?skip)
        {
            var subject = new FindCommandOperation <BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                Skip = skip
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription();
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "find", _collectionNamespace.CollectionName },
                { "skip", () => skip.Value, skip.HasValue }
            };

            result.Should().Be(expectedResult);
        }
Example #23
0
        public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long maxTimeTicks, int expectedMaxTimeMS)
        {
            var subject = new FindOneAndReplaceOperation <BsonDocument>(_collectionNamespace, _filter, _replacement, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                MaxTime = TimeSpan.FromTicks(maxTimeTicks)
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription, null);

            var expectedResult = new BsonDocument
            {
                { "findAndModify", _collectionNamespace.CollectionName },
                { "query", _filter },
                { "update", _replacement },
                { "maxTimeMS", expectedMaxTimeMS }
            };

            result.Should().Be(expectedResult);
            result["maxTimeMS"].BsonType.Should().Be(BsonType.Int32);
        }
Example #24
0
        public void CreateCommand_should_return_expected_result_when_Sort_is_set(
            [Values(null, "{ x : 1 }", "{ y : 1 }")]
            string sortString)
        {
            var sort    = sortString == null ? null : BsonDocument.Parse(sortString);
            var subject = new FindCommandOperation <BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                Sort = sort
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription();
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "find", _collectionNamespace.CollectionName },
                { "sort", sort, sort != null }
            };

            result.Should().Be(expectedResult);
        }
Example #25
0
        public void CreateCommand_should_return_expected_result_when_ReadConcern_is_set(
            [Values(null, ReadConcernLevel.Linearizable, ReadConcernLevel.Local)]
            ReadConcernLevel?level)
        {
            var readConcern = level.HasValue ? new ReadConcern(level.Value) : ReadConcern.Default;
            var subject     = new FindCommandOperation <BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                ReadConcern = readConcern
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription(Feature.ReadConcern.FirstSupportedVersion);
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "find", _collectionNamespace.CollectionName },
                { "readConcern", () => readConcern.ToBsonDocument(), readConcern != null && !readConcern.IsServerDefault }
            };

            result.Should().Be(expectedResult);
        }
Example #26
0
        public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(
            [Values(null, 1, 2)]
            int?seconds)
        {
            var maxTime = seconds.HasValue ? TimeSpan.FromSeconds(seconds.Value) : (TimeSpan?)null;
            var subject = new FindCommandOperation <BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                MaxTime = maxTime
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription();
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "find", _collectionNamespace.CollectionName },
                { "maxTimeMS", () => seconds.Value * 1000, seconds.HasValue }
            };

            result.Should().Be(expectedResult);
        }
Example #27
0
        public void CreateCommand_should_return_expected_result_when_CursorType_is_Set(
            [Values(CursorType.NonTailable, CursorType.Tailable, CursorType.TailableAwait)]
            CursorType cursorType)
        {
            var subject = new FindCommandOperation <BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                CursorType = cursorType
            };

            var connectionDescription = OperationTestHelper.CreateConnectionDescription();
            var session = OperationTestHelper.CreateSession();

            var result = subject.CreateCommand(connectionDescription, session);

            var expectedResult = new BsonDocument
            {
                { "find", _collectionNamespace.CollectionName },
                { "tailable", true, cursorType == CursorType.Tailable || cursorType == CursorType.TailableAwait },
                { "awaitData", true, cursorType == CursorType.TailableAwait }
            };

            result.Should().Be(expectedResult);
        }
Example #28
0
        public void CreateCommand_should_return_expected_result_when_ReturnDocument_is_set(
            [Values(ReturnDocument.After, ReturnDocument.Before)]
            ReturnDocument value)
        {
            var subject = new FindOneAndReplaceOperation <BsonDocument>(_collectionNamespace, _filter, _replacement, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                ReturnDocument = value
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription, null);

            var expectedResult = new BsonDocument
            {
                { "findAndModify", _collectionNamespace.CollectionName },
                { "query", _filter },
                { "update", _replacement },
                { "new", () => true, value == ReturnDocument.After }
            };

            result.Should().Be(expectedResult);
        }
Example #29
0
        public void CreateCommand_should_return_expected_result_when_Hint_is_set(
            [Values(null, "_id_")] string hintString)
        {
            var hint    = (BsonValue)hintString;
            var subject = new FindOneAndReplaceOperation <BsonDocument>(_collectionNamespace, _filter, _replacement, BsonDocumentSerializer.Instance, _messageEncoderSettings)
            {
                Hint = hint
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription(serverVersion: Feature.HintForFindAndModifyFeature.FirstSupportedVersion);

            var result = subject.CreateCommand(session, connectionDescription, null);

            var expectedResult = new BsonDocument
            {
                { "findAndModify", _collectionNamespace.CollectionName },
                { "query", _filter },
                { "update", _replacement },
                { "hint", () => hint, hint != null }
            };

            result.Should().Be(expectedResult);
        }
        public void CreateCommand_should_return_expected_result_when_Comment_is_set(
            [Values(null, "test")]
            string comment)
        {
            var subject = new AggregateToCollectionOperation(_collectionNamespace, __pipeline, _messageEncoderSettings)
            {
                Comment = comment,
            };
            var session = OperationTestHelper.CreateSession();
            var connectionDescription = OperationTestHelper.CreateConnectionDescription();

            var result = subject.CreateCommand(session, connectionDescription);

            var expectedResult = new BsonDocument
            {
                { "aggregate", _collectionNamespace.CollectionName },
                { "pipeline", new BsonArray(__pipeline) },
                { "cursor", new BsonDocument() },
                { "comment", () => comment, comment != null }
            };

            result.Should().Be(expectedResult);
        }