public async Task NoMxRecordReturnFromClientReturnsNull() { string[] records = new string[0]; string domain = "abc.gov.uk"; Response dnsQueryResponse = CreateRecord(domain, records); A.CallTo(() => _dnsResolver.GetRecord(A <string> ._, A <QType> ._)).Returns(Task.FromResult(dnsQueryResponse)); DnsResponse mxRecords = await _mxRecordDnsClient.GetRecord(domain); Assert.That(mxRecords.Records.Count, Is.EqualTo(1)); Assert.That(mxRecords.Records[0], Is.EqualTo(MxRecordInfo.EmptyRecordInfo)); }
public virtual async Task <DnsResponse> GetRecord(string domain) { Response response = await _dnsResolver.GetRecord(FormatQuery(domain), _recordType); List <RecordInfo> dnsRecords = GetRecords(response); if (response.header.RCODE == RCode.NoError || response.header.RCODE == RCode.NXDomain) { string records = string.Join(Environment.NewLine, dnsRecords); _log.Trace($"Found following { _recordName } records for {domain}: {Environment.NewLine}{records}"); } else { _log.Error($"Failed to retrieve { _recordName } records with RCODE: {response.header.RCODE}"); } return(new DnsResponse(dnsRecords, response.header.RCODE)); }