public void DNSHelperTest() { Assert.AreEqual(IPAddress.Parse("208.67.222.222"), DNSHelper.OpenDNS1); Assert.AreEqual(IPAddress.Parse("208.67.220.220"), DNSHelper.OpenDNS2); var dnsServers = DNSHelper.GetLocalDNS(); Assert.IsTrue(dnsServers.Any()); foreach (var dnsServer in dnsServers) { Request request = new Request(); request.AddQuestion(new Question("google.com", DnsType.ANAME, DnsClass.IN)); Response response = Resolver.Lookup(request, dnsServer); var address = ((ANameRecord)response.Answers[0].Record).IPAddress; Assert.IsNotNull(address); } }
public void CorrectANameForCodeProject() { // also 194.72.0.114 // create a new request var request = new Request(); // add the codeproject ANAME question request.AddQuestion(new Question("codeproject.com", DnsType.ANAME, DnsClass.IN)); // send the request Response response = null; multiDnsServerAction.Invoke( dnsServer => response = Resolver.Lookup(request, dnsServer)); // check the reponse Assert.AreEqual(ReturnCode.Success, response.ReturnCode); Assert.AreEqual(1, response.Answers.Length); var record = (ANameRecord) response.Answers[0].Record; Assert.AreEqual(IPAddress.Parse("65.39.148.34"), record.IPAddress); }
public void CorrectNSForCodeProject() { // also 194.72.0.114 // create a new request var request = new Request(); // add the codeproject ANAME question request.AddQuestion(new Question("codeproject.com", DnsType.NS, DnsClass.IN)); // send the request Response response = null; multiDnsServerAction.Invoke(dnsServer => response= Resolver.Lookup(request, dnsServer)); // check the reponse Assert.AreEqual(ReturnCode.Success, response.ReturnCode); // we expect 4 records Assert.IsTrue(response.Answers.Length>0); }
public void RepeatedANameLookups() { var request = new Request(); // add the codeproject ANAME question request.AddQuestion(new Question("codeproject.com", DnsType.ANAME, DnsClass.IN)); for (int i = 0; i < 1000; i++) { // send the request Response response = null; multiDnsServerAction.Invoke( dnsServer => response = Resolver.Lookup(request, dnsServer)); // check the reponse Assert.AreEqual(ReturnCode.Success, response.ReturnCode); Assert.AreEqual(1, response.Answers.Length); } }