Esempio n. 1
0
        public void GetIPWhenValidHostShouldReturnFirstValidAddressFromAdressList()
        {
            DNSClientSide dnsClient = new DNSClientSide();

            string hostIP = dnsClient.GetIP("www.google.com");

            Assert.True(IPAddress.TryParse(hostIP, out IPAddress address));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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()));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        public void GetIPWhenNullStringShouldThrowException()
        {
            DNSClientSide dnsClient = new DNSClientSide();

            Assert.Throws <ArgumentNullException>(() => dnsClient.GetIP(null));
        }
Esempio n. 6
0
        public void GetIPWhenNotResolvingHostShouldThrowException()
        {
            DNSClientSide dnsClient = new DNSClientSide();

            Assert.Throws <SocketException>(() => dnsClient.GetIP("invalidIPaddress"));
        }
Esempio n. 7
0
        public void GetIPWhenHostIsInvalidIPShouldThrowException()
        {
            DNSClientSide dnsClient = new DNSClientSide();

            Assert.Throws <ArgumentException>(() => dnsClient.GetIP("0.0.0.0"));
        }