示例#1
0
        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");
        }
示例#2
0
        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);
        }
示例#3
0
        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>();
        }