public void AddClientDocumentToCommand_with_ConnectionInitializer_client_document_should_return_expected_result() { var command = IsMasterHelper.CreateCommand(); var connectionInitializer = new ConnectionInitializer("test", new CompressorConfiguration[0], serverApi: null); var subjectClientDocument = (BsonDocument)Reflector.GetFieldValue(connectionInitializer, "_clientDocument"); var result = IsMasterHelper.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 CreateInitialIsMasterCommand(IReadOnlyList <IAuthenticator> authenticators) { var command = IsMasterHelper.CreateCommand(); IsMasterHelper.AddClientDocumentToCommand(command, _clientDocument); return(IsMasterHelper.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 = IsMasterHelper.CreateCommand(); var result = IsMasterHelper.AddClientDocumentToCommand(command, clientDocument); result.Should().Be($"{{ isMaster : 1, client : {clientDocumentString} }}"); }