public void TestLookupWithOneVisitor() { lookup.Visitors.Add(new FakeWhoisVisitor("first")); var result = lookup.Lookup("example.com"); Assert.AreEqual("first", result.ToString()); }
public void TestBasicLookup() { // Create a WhoisLookup instance var whois = new WhoisLookup(); // Query github.com var response = whois.Lookup("github.com"); // Output the response Console.WriteLine(response.Content); }
public void TestCustomNetworking() { // Create a WhoisLookup instance var lookup = new WhoisLookup(); // Assign the custom TcpReader lookup.TcpReader = new MyCustomTcpReader(); // Lookups will now use the custom TcpReader var response = lookup.Lookup("github.com"); Console.WriteLine(response.Content); }
public void TestParsedLookup() { // Create a WhoisLookup instance var whois = new WhoisLookup(); // Query github.com var response = whois.Lookup("github.com"); // Convert the response to JSON var json = JsonConvert.SerializeObject(response, Formatting.Indented); // Output the json Console.WriteLine(json); }
public void DownloadTop500DomainAsSamples() { var lines = File.ReadAllLines(@"..\..\Data\top-500.txt"); foreach (var line in lines) { var fileName = string.Format(@"..\..\..\Whois.Tests\Samples\Domains\{0}.txt", line); if (File.Exists(fileName)) { continue; } var whois = lookup.Lookup(line); Console.WriteLine("Writing: {0}, {1:###,##0} byte(s)", line, whois.ToString().Length); File.WriteAllText(fileName, whois.ToString()); Thread.Sleep(60000); } }
public void TestDownloadSampleDomainsSingleThreaded() { var domains = new SampleReader().ReadSampleDomains(); foreach (var domain in domains) { Console.WriteLine($"Looking Up: {domain.DomainName}"); WhoisResponse response = null; try { response = lookup.Lookup(domain.DomainName); Console.WriteLine($"Looked Up: {domain.DomainName}, Status: {response.Status}, Size: {response.Content.Length}"); } catch (Exception e) { Console.WriteLine($"FAIL: {response?.DomainName}: {e.Message}"); } Thread.Sleep(1000); } }
public void TestLookupDomainWithEmptyQuery() { Assert.Throws <ArgumentNullException>(() => lookup.Lookup(string.Empty)); }