public void AddClientDocumentToCommand_with_ConnectionInitializer_client_document_should_return_expected_result()
        {
            var command = HelloHelper.CreateCommand();
            var connectionInitializer = new ConnectionInitializer("test", new CompressorConfiguration[0], serverApi: null);
            var subjectClientDocument = (BsonDocument)Reflector.GetFieldValue(connectionInitializer, "_clientDocument");
            var result = HelloHelper.AddClientDocumentToCommand(command, subjectClientDocument);

            var names = result.Names.ToList();

            names.Count.Should().Be(2);
            names[0].Should().Be("isMaster");
            names[1].Should().Be("client");
            result[0].Should().Be(1);
            var clientDocument      = result[1].AsBsonDocument;
            var clientDocumentNames = clientDocument.Names.ToList();

            clientDocumentNames.Count.Should().Be(4);
            clientDocumentNames[0].Should().Be("application");
            clientDocumentNames[1].Should().Be("driver");
            clientDocumentNames[2].Should().Be("os");
            clientDocumentNames[3].Should().Be("platform");
            clientDocument["application"]["name"].AsString.Should().Be("test");
            clientDocument["driver"]["name"].AsString.Should().Be("mongo-csharp-driver");
            clientDocument["driver"]["version"].BsonType.Should().Be(BsonType.String);
        }
        private BsonDocument CreateInitialHelloCommand(IReadOnlyList <IAuthenticator> authenticators, bool loadBalanced = false)
        {
            var command = HelloHelper.CreateCommand(_serverApi, loadBalanced: loadBalanced);

            HelloHelper.AddClientDocumentToCommand(command, _clientDocument);
            HelloHelper.AddCompressorsToCommand(command, _compressors);
            return(HelloHelper.CustomizeCommand(command, authenticators));
        }
        private BsonDocument CreateInitialHelloCommand(IReadOnlyList <IAuthenticator> authenticators)
        {
            var command = HelloHelper.CreateCommand();

            HelloHelper.AddClientDocumentToCommand(command, _clientDocument);
            HelloHelper.AddCompressorsToCommand(command, _compressors);
            return(HelloHelper.CustomizeCommand(command, authenticators));
        }
        public void AddClientDocumentToCommand_with_custom_document_should_return_expected_result(
            [Values("{ client : { driver : 'dotnet', version : '2.4.0' }, os : { type : 'Windows' } }")]
            string clientDocumentString)
        {
            var clientDocument = BsonDocument.Parse(clientDocumentString);
            var command        = HelloHelper.CreateCommand();
            var result         = HelloHelper.AddClientDocumentToCommand(command, clientDocument);

            result.Should().Be($"{{ isMaster : 1, client : {clientDocumentString} }}");
        }
        public void AddClientDocumentToCommand_with_custom_document_should_return_expected_result(
            [Values("{ client : { driver : 'dotnet', version : '3.6.0' }, os : { type : 'Windows' } }")]
            string clientDocumentString)
        {
            var clientDocument = BsonDocument.Parse(clientDocumentString);
            var command        = HelloHelper.CreateCommand(null);
            var result         = HelloHelper.AddClientDocumentToCommand(command, clientDocument);

            result.Should().Be($"{{ {OppressiveLanguageConstants.LegacyHelloCommandName} : 1, helloOk : true, client : {clientDocumentString} }}");
        }