private async Task <List <ReverseDnsResponse> > GetDnsResponses <T>(List <string> hosts, QueryType queryType)
            where T : AddressRecord
        {
            List <ReverseDnsResponse> responses = new List <ReverseDnsResponse>();

            foreach (var host in hosts)
            {
                List <string> ipAddresses = new List <string>();

                if (!string.IsNullOrWhiteSpace(host))
                {
                    ReverseDnsQueryResponse forward = await _dnsResolver.QueryAddressAsync <T>(host, queryType);

                    if (!forward.HasError)
                    {
                        ipAddresses.AddRange(forward.Results);
                        responses.Add(new ReverseDnsResponse(host, ipAddresses));
                    }
                    else
                    {
                        _log.LogWarning("Failed to do dns query type: {QueryType} for {Host} with error: {Error}.",
                                        queryType, host, forward.ErrorMessage ?? "Unknown error");
                    }
                }
            }

            return(responses);
        }
        public async Task ItShouldLogErrorWhenValidPtrButFailsOnForwardLookup(string ipAddress)
        {
            ReverseDnsQueryResponse ptrDnsQueryResponse = new ReverseDnsQueryResponse(false, string.Empty, new List <string>()
            {
                "google.com"
            });
            ReverseDnsQueryResponse addressDnsQueryResponse = new ReverseDnsQueryResponse(true, "Something has gone wrong!", null);

            A.CallTo(() => _dnsResolver.QueryPtrAsync(A <IPAddress> ._)).Returns(ptrDnsQueryResponse);
            A.CallTo(() => _dnsResolver.QueryAddressAsync <ARecord>(A <string> ._, QueryType.A)).Returns(addressDnsQueryResponse);
            A.CallTo(() => _dnsResolver.QueryAddressAsync <AaaaRecord>(A <string> ._, QueryType.AAAA)).Returns(addressDnsQueryResponse);

            var reverseDnsLookup = new ReverseDnsLookup(_dnsResolver, _log);

            ReverseDnsResult reverseDnsResult = await reverseDnsLookup.Lookup(ipAddress);

            Assert.That(_log.Warnings.Count, Is.EqualTo(1));
            Assert.That(reverseDnsResult.ForwardResponses.Count, Is.EqualTo(0));
        }