本文整理汇总了C#中System.Net.Request.AddQuestion方法的典型用法代码示例。如果您正苦于以下问题:C# Request.AddQuestion方法的具体用法?C# Request.AddQuestion怎么用?C# Request.AddQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Request
的用法示例。
在下文中一共展示了Request.AddQuestion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DNSHelperTest
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);
}
}
示例2: CorrectANameForCodeProject
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);
}
示例3: CorrectNSForCodeProject
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);
}
示例4: RepeatedANameLookups
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);
}
}