public void LookupClient_should_return_expected_result() { var subject = new DnsClientWrapper(); var result = subject.LookupClient; result.Should().NotBeNull(); }
public void ResolveSrvRecords_should_throw_when_service_is_null(bool async) { var subject = new DnsClientWrapper(); Exception exception; if (async) { exception = Record.Exception(() => subject.ResolveSrvRecords(null, CancellationToken.None)); } else { exception = Record.Exception(() => subject.ResolveSrvRecordsAsync(null, CancellationToken.None).GetAwaiter().GetResult()); } var e = exception.Should().BeOfType <ArgumentNullException>().Subject; e.ParamName.Should().Be("service"); }
public void ResolveSrvRecords_should_return_expected_result(string service, string[] expectedEndPoints, bool async) { var subject = new DnsClientWrapper(); List <SrvRecord> result; if (async) { result = subject.ResolveSrvRecords(service, CancellationToken.None); } else { result = subject.ResolveSrvRecordsAsync(service, CancellationToken.None).GetAwaiter().GetResult(); } var actualEndPoints = result.Select(s => EndPointHelper.ToString(s.EndPoint)).ToList(); actualEndPoints.Should().BeEquivalentTo(expectedEndPoints); }
public void ResolveTxtRecords_should_return_expected_result(string domainName, string expectedString, bool async) { var subject = new DnsClientWrapper(); List <TxtRecord> result; if (async) { result = subject.ResolveTxtRecords(domainName, CancellationToken.None); } else { result = subject.ResolveTxtRecordsAsync(domainName, CancellationToken.None).GetAwaiter().GetResult(); } result.Should().HaveCount(1); result[0].Strings.Should().HaveCount(1); result[0].Strings[0].Should().Be(expectedString); }
public void ResolveSrvRecords_should_throw_when_cancellation_is_already_requested(bool async) { var subject = new DnsClientWrapper(); var service = "_mongodb._tcp.test5.test.build.10gen.cc"; var cts = new CancellationTokenSource(); cts.Cancel(); Exception exception; if (async) { exception = Record.Exception(() => subject.ResolveSrvRecords(service, cts.Token)); } else { exception = Record.Exception(() => subject.ResolveSrvRecordsAsync(service, cts.Token).GetAwaiter().GetResult()); } exception.Should().BeOfType <OperationCanceledException>(); }
public void ResolveTxtRecords_should_throw_when_cancellation_is_already_requested(bool async) { var subject = new DnsClientWrapper(); var domainName = "test5.test.build.10gen.cc"; var cts = new CancellationTokenSource(); cts.Cancel(); Exception exception; if (async) { exception = Record.Exception(() => subject.ResolveTxtRecords(domainName, cts.Token)); } else { exception = Record.Exception(() => subject.ResolveTxtRecordsAsync(domainName, cts.Token).GetAwaiter().GetResult()); } exception.Should().Match <Exception>(e => e is OperationCanceledException || e.InnerException is OperationCanceledException); }
public void constructor_should_initialize_instance() { var subject = new DnsClientWrapper(); subject.LookupClient.Should().NotBeNull(); }