public async Task TestResolveAsyncWithASrvUrl() { // NOTE: this requires SRV and TXT records in DNS as specified here: // https://github.com/mongodb/specifications/tree/master/source/initial-dns-seedlist-discovery var connectionString = "mongodb+srv://user%40GSSAPI.COM:[email protected]/funny?replicaSet=rs0"; var subject = new MongoUrl(connectionString); var resolved = await subject.ResolveAsync(); Assert.Equal("mongodb://user%40GSSAPI.COM:[email protected]/funny?authSource=thisDB;tls=true;replicaSet=rs0", resolved.ToString()); }
public void Resolve_with_srvMaxHosts_should_return_expected_result(string url, bool resolveHosts, int expectedSrvMaxHosts, bool async) { var subject = new MongoUrl(url); MongoUrl result; if (async) { result = subject.ResolveAsync(resolveHosts).GetAwaiter().GetResult(); } else { result = subject.Resolve(resolveHosts); } result.SrvMaxHosts.Should().Be(expectedSrvMaxHosts); }
public void Resolve_with_resolveHosts_should_return_expected_result(string url, bool resolveHosts, string expectedServer, bool async) { var subject = new MongoUrl(url); MongoUrl result; if (async) { result = subject.Resolve(resolveHosts); } else { result = subject.ResolveAsync(resolveHosts).GetAwaiter().GetResult(); } var expectedServers = new[] { MongoServerAddress.Parse(expectedServer) }; result.Servers.Should().Equal(expectedServers); }