GetIpAddressForHostname() public method

Submits a dns request for the given hostname and returns the IP address that it resolves to.
public GetIpAddressForHostname ( string hostname ) : string
hostname string The hostname to get an IP address for.
return string
        public void CanGetIpAddressForHostname()
        {
            var resolver = new IpAddressResolver();
            var ip = resolver.GetIpAddressForHostname("bespokeindustries.com");

            Assert.AreEqual("204.246.37.132", ip);
        }
        public void GetIpAddressForInvalidHostnameReturnsNull()
        {
            var resolver = new IpAddressResolver();
            var ip = resolver.GetIpAddressForHostname("bogus93937329923.bespokeindustries.com");

            Assert.IsNull(ip);
        }
        /// <summary>
        /// Initialize the LastUpdateIpAddresses collection with the current IP Address (in DNS) for each of the given hostnames.
        /// This can be used when the client is run for the first time, when we don't have a record of what the previous IP
        /// Address was that was sent to DNS-O-Matic.  This way we won't have to attempt to update the IP Address, if the current
        /// DNS entry matches the current IP Address.
        /// </summary>
        /// <param name="hostnames">The hostnames to update.</param>
        public void InitializeLastUpdateIpAddresses(string hostnames)
        {
            var resolver      = new IpAddressResolver();
            var hostnamesList = HostnamesToList(hostnames);

            foreach (var hostname in hostnamesList)
            {
                var ipAddress = resolver.GetIpAddressForHostname(hostname);

                if (ipAddress != null)
                {
                    LastUpdateIpAddresses[hostname] = ipAddress;
                }
            }
        }
        /// <summary>
        /// Initialize the LastUpdateIpAddresses collection with the current IP Address (in DNS) for each of the given hostnames.
        /// This can be used when the client is run for the first time, when we don't have a record of what the previous IP
        /// Address was that was sent to DNS-O-Matic.  This way we won't have to attempt to update the IP Address, if the current
        /// DNS entry matches the current IP Address.
        /// </summary>
        /// <param name="hostnames">The hostnames to update.</param>
        public void InitializeLastUpdateIpAddresses(string hostnames)
        {
            var resolver = new IpAddressResolver();
            var hostnamesList = HostnamesToList(hostnames);

            foreach (var hostname in hostnamesList)
            {
                var ipAddress = resolver.GetIpAddressForHostname(hostname);

                if (ipAddress != null)
                {
                    LastUpdateIpAddresses[hostname] = ipAddress;
                }
            }
        }