public void TestReadWhoisForCogworksCoUk() { string result; using (var reader = new TcpReader()) { result = reader.Read("whois.nic.uk", 43, "cogworks.co.uk"); } // Just check the domain name is in the response Assert.Greater(result.IndexOf("cogworks.co.uk"), -1); }
public void TestReadWhoisForUnknownDomain() { string result; using (var reader = new TcpReader()) { result = reader.Read("whois.nic.uk", 43, "invalid domain"); } // SHould never be registered (as invalid) Assert.AreEqual(result.IndexOf("Registered on:"), -1); }
public async Task TestReadWhoisForUolComBr() { string result; using (var reader = new TcpReader()) { result = await reader.Read("registro.br", 43, "uol.com.br", Encoding.GetEncoding("ISO-8859-1")); } // Just check the domain name is in the response Assert.Greater(result.IndexOf("uol.com.br"), -1); }
public async Task TestReadWhoisForSapoPt() { string result; using (var reader = new TcpReader()) { result = await reader.Read("whois.dns.pt", 43, "sapo.pt", Encoding.GetEncoding("ISO-8859-1")); } // Just check the domain name is in the response Assert.Greater(result.IndexOf("sapo.pt"), -1); }
public void TestReadWhoisForSapoPt() { string result; var encoding = Encoding.GetEncoding("ISO-8859-1"); using (var reader = new TcpReader(encoding)) { result = reader.Read("whois.dns.pt", 43, "sapo.pt"); } // Just check the domain name is in the response Assert.Greater(result.IndexOf("sapo.pt"), -1); }
/// <summary> /// Creates an <see cref="ITcpReader"/> object. /// </summary> /// <param name="encoding">The encoding used to read and write strings.</param> /// <returns></returns> public ITcpReader Create(Encoding encoding) { ITcpReader reader; var cachePath = Environment.GetEnvironmentVariable("WHOIS_CACHE_PATH"); if (string.IsNullOrEmpty(cachePath)) { reader = new TcpReader(encoding); } else { reader = new TcpReaderFileCache(); } return(reader); }
public void TestReadWhenInvalidHost() { try { using (var reader = new TcpReader()) { reader.Read("invalid domain", 43, "invalid domain"); } Assert.Fail("Should of thrown an exception!"); } catch (ApplicationException) { // Should thrown an exception } catch (Exception) { Assert.Fail("Thrown an unexpected exception!"); } }
public async Task TestReadWhenInvalidHost() { try { using (var reader = new TcpReader()) { await reader.Read("invalid domain", 43, "invalid domain", Encoding.UTF8); } Assert.Fail("Should of thrown an exception!"); } catch (WhoisException) { // Should thrown an exception } catch (Exception) { Assert.Fail("Thrown an unexpected exception!"); } }
/// <summary> /// Initializes a new instance of the <see cref="TcpReaderFileCache"/> class. /// </summary> public TcpReaderFileCache() { Actual = new TcpReader(); FileStore = new FileStore(); }