public void ResolveTxtRecords_should_throw_when_domainName_is_null(bool async) { var subject = new DnsClientWrapper(); Exception exception; if (async) { exception = Record.Exception(() => subject.ResolveTxtRecords(null, CancellationToken.None)); } else { exception = Record.Exception(() => subject.ResolveTxtRecordsAsync(null, CancellationToken.None).GetAwaiter().GetResult()); } var e = exception.Should().BeOfType <ArgumentNullException>().Subject; e.ParamName.Should().Be("domainName"); }
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 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().BeOfType <OperationCanceledException>(); }