public void GetIPWhenValidHostShouldReturnFirstValidAddressFromAdressList() { DNSClientSide dnsClient = new DNSClientSide(); string hostIP = dnsClient.GetIP("www.google.com"); Assert.True(IPAddress.TryParse(hostIP, out IPAddress address)); }
public void GetIPWhenHostIsIPShouldReturnSameIP() { DNSClientSide dnsClient = new DNSClientSide(); string hostIP = dnsClient.GetIP("78.96.7.88"); Assert.True(IPAddress.TryParse(hostIP, out IPAddress address)); Assert.Equal("78.96.7.88", hostIP); }
public void GetIPWhenEmptyStringShouldReturnFirstValidAddressFromHostRunningClient() { DNSClientSide dnsClient = new DNSClientSide(); string hostIP = dnsClient.GetIP(""); Assert.True(IPAddress.TryParse(hostIP, out IPAddress address)); Assert.Contains <IPAddress>(address, Dns.GetHostAddresses(Dns.GetHostName())); }
public void GetIPWhenHostLengthIsGreaterThan255CharactersShouldThrowException() { DNSClientSide dnsClient = new DNSClientSide(); string hostName = "www.t"; for (int i = 0; i < 255; i++) { hostName += "o"; } hostName += ".long"; Assert.Throws <ArgumentOutOfRangeException>(() => dnsClient.GetIP(hostName)); }
public void GetIPWhenNullStringShouldThrowException() { DNSClientSide dnsClient = new DNSClientSide(); Assert.Throws <ArgumentNullException>(() => dnsClient.GetIP(null)); }
public void GetIPWhenNotResolvingHostShouldThrowException() { DNSClientSide dnsClient = new DNSClientSide(); Assert.Throws <SocketException>(() => dnsClient.GetIP("invalidIPaddress")); }
public void GetIPWhenHostIsInvalidIPShouldThrowException() { DNSClientSide dnsClient = new DNSClientSide(); Assert.Throws <ArgumentException>(() => dnsClient.GetIP("0.0.0.0")); }