Merge pull request #249 from pcc/xgetinputfocus
[mono.git] / mcs / class / System / Test / System.Net / DnsTest.cs
index de781f2350812ab5b3dbc692127989d9c196a33e..6b8e87f533d6be238ada2dc2e9c9a82a80443fea 100644 (file)
 // \r
 // This test assumes the following:\r
 // 1) The following Internet sites exist:\r
-//        www.go-mono.com with IP address 64.14.94.132\r
+//        www.go-mono.com with IP address 64.14.94.188\r
 //        info.diku.dk with IP address 130.225.96.4\r
 // 2) The following DNS name does not exist:\r
 //        www.hopefullydoesnotexist.dk\r
 //\r
 \r
-using NUnit.Framework;\r
 using System;\r
+using System.Collections;\r
 using System.Net;\r
 using System.Net.Sockets;\r
 using System.Threading;\r
-using System.Collections;\r
 \r
-namespace MonoTests.System.Net {\r
-\r
-[TestFixture]\r
-public class DnsTest : Assertion {\r
-        \r
-        private String site1Name = "www.go-mono.com",\r
-                site1Dot = "64.14.94.132",\r
-                site2Name = "info.diku.dk",\r
-                site2Dot = "130.225.96.4",\r
-                noneExistingSite = "www.hopefullydoesnotexist.dk";\r
-        private uint site1IP = 2180692201, site2IP = 2195808260; // Big-Endian\r
-        \r
-        private void Callback(IAsyncResult ar) { \r
-                IPHostEntry h;\r
-                h = Dns.EndGetHostByName(ar);\r
-                SubTestValidIPHostEntry(h);\r
-        }\r
-\r
-       [Test]\r
-        public void AsyncGetHostByName(){\r
-                IAsyncResult r;\r
-                r = Dns.BeginGetHostByName(site1Name, new AsyncCallback(Callback), null);\r
-                \r
-               IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);\r
-               IPHostEntry entry = Dns.EndGetHostByName (async);                \r
-               SubTestValidIPHostEntry(entry);\r
-               AssertEquals ("#1", "www.go-mono.com", entry.HostName);\r
-        }\r
-        \r
-       [Test]\r
-        public void AsyncResolve() {\r
-                IAsyncResult r;\r
-                r = Dns.BeginResolve(site1Name, new AsyncCallback(Callback), null);\r
-\r
-               IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);\r
-               IPHostEntry entry = Dns.EndResolve (async);                \r
-               SubTestValidIPHostEntry(entry);\r
-               AssertEquals ("#1", site1Dot, entry.HostName);\r
-        }\r
-        \r
-       [Test]\r
-        public void GetHostName() {\r
-                string hostName = Dns.GetHostName();\r
-                AssertNotNull (hostName);\r
-        }\r
-        \r
-        private void SubTestGetHostByName(string siteName, string siteDot) {\r
-                IPHostEntry h = Dns.GetHostByName(siteName);\r
-                SubTestValidIPHostEntry(h);\r
-                AssertEquals ("siteName", siteName, h.HostName);\r
-                AssertEquals ("siteDot", siteDot, h.AddressList[0].ToString());\r
-        }\r
-        \r
-       [Test]\r
-        public void GetHostByName() {\r
-                SubTestGetHostByName(site1Name, site1Dot);\r
-                SubTestGetHostByName(site2Name, site2Dot);\r
-                try {\r
-                        Dns.GetHostByName(noneExistingSite);\r
-                        Fail("Should raise a SocketException (assuming that '" + noneExistingSite + "' does not exist)");\r
-                } catch (SocketException) {\r
-                } \r
-                try {\r
-                        Dns.GetHostByName(null);\r
-                        Fail("Should raise an ArgumentNullException");\r
-                } catch (ArgumentNullException) {\r
-                } \r
-        }\r
-        \r
-        private void SubTestGetHostByAddressString(string addr) {\r
-                IPHostEntry h = Dns.GetHostByAddress(addr);\r
-                SubTestValidIPHostEntry(h);\r
-        }\r
-        \r
-       [Test, ExpectedException (typeof (ArgumentNullException))]\r
-        public void GetHostByAddressString1() {\r
-                String addr = null;\r
-                Dns.GetHostByAddress(addr);\r
-       }\r
+using NUnit.Framework;\r
 \r
-       [Test, ExpectedException (typeof (SocketException))]\r
-        public void GetHostByAddressString2() {\r
-               Dns.GetHostByAddress ("123.255.23");\r
-       }\r
+namespace MonoTests.System.Net\r
+{\r
+       [TestFixture]\r
+       public class DnsTest\r
+       {\r
+               private String site1Name = "go-mono.com",\r
+                       site1Dot = "74.208.222.19",\r
+                       site2Name = "info.diku.dk",\r
+                       site2Dot = "130.225.96.4",\r
+                       noneExistingSite = "www.unlikely.novell.com";\r
+               private uint site1IP = 1255202323, site2IP = 2195808260; // Big-Endian\r
 \r
-       [Test, ExpectedException (typeof (FormatException))]\r
-        public void GetHostByAddressString3() {\r
-               Dns.GetHostByAddress ("123.256.34.10");\r
-       }\r
+               [Test]\r
+               public void AsyncGetHostByName ()\r
+               {\r
+                       IAsyncResult r;\r
+                       r = Dns.BeginGetHostByName (site1Name, new AsyncCallback (GetHostByNameCallback), null);\r
 \r
-       [Test, ExpectedException (typeof (FormatException))]\r
-        public void GetHostByAddressString4() {\r
-               Dns.GetHostByAddress ("not an IP address");\r
-       }\r
+                       IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);\r
+                       IPHostEntry entry = Dns.EndGetHostByName (async);\r
+                       SubTestValidIPHostEntry (entry);\r
+                       Assert.AreEqual ("go-mono.com", entry.HostName);\r
+               }\r
 \r
-       [Test, ExpectedException (typeof (SocketException))]\r
-        public void GetHostByAddressString5() {\r
-               Dns.GetHostByAddress (site1Dot);\r
-       }\r
+               void GetHostByNameCallback (IAsyncResult ar)\r
+               {\r
+                       IPHostEntry h;\r
+                       h = Dns.EndGetHostByName (ar);\r
+                       SubTestValidIPHostEntry (h);\r
+               }\r
 \r
-       [Test, ExpectedException (typeof (ArgumentNullException))]\r
-        public void GetHostByAddressIPAddress1() {\r
-                IPAddress addr = null;\r
-                Dns.GetHostByAddress(addr);\r
-       }\r
+               [Test]\r
+               public void AsyncResolve ()\r
+               {\r
+                       IAsyncResult r;\r
+                       r = Dns.BeginResolve (site1Name, new AsyncCallback (ResolveCallback), null);\r
 \r
-        public void GetHostByAddressIPAddress2() {\r
-               IPAddress addr = new IPAddress(IPAddress.NetworkToHostOrder((int)site1IP));\r
-                IPHostEntry h = Dns.GetHostByAddress(addr);\r
-                SubTestValidIPHostEntry(h);\r
-                AssertEquals (addr.ToString(), h.AddressList[0].ToString());\r
-        }\r
-        \r
-        public void GetHostByAddressIPAddress3() {\r
-               IPAddress addr = new IPAddress(IPAddress.NetworkToHostOrder((int)site2IP));\r
-                IPHostEntry h = Dns.GetHostByAddress(addr);\r
-                SubTestValidIPHostEntry(h);\r
-                AssertEquals (addr.ToString(), h.AddressList[0].ToString());\r
-        }\r
-\r
-       private void SubTestResolve(string addr) {\r
-                IPHostEntry h = Dns.Resolve(addr);\r
-                SubTestValidIPHostEntry(h);\r
-        }\r
-        \r
-       [Test]\r
-        public void Resolve() {\r
-                SubTestResolve(site1Name);\r
-                SubTestResolve(site2Name);\r
-                SubTestResolve(site1Dot);\r
-                SubTestResolve(site2Dot);\r
-        }\r
-        \r
-        private void SubTestValidIPHostEntry(IPHostEntry h) {\r
-                AssertNotNull ("HostName not null", h.HostName);\r
-                AssertNotNull ("AddressList not null", h.AddressList);\r
-                Assert ("AddressList.Length", h.AddressList.Length > 0);\r
-        }\r
-/* This isn't used anymore, but could be useful for debugging         \r
-        private static void printIPHostEntry(IPHostEntry h)\r
-        {\r
-                Console.WriteLine("----------------------------------------------------");\r
-                Console.WriteLine("Host name:");\r
-                Console.WriteLine(h.HostName);\r
-                Console.WriteLine("IP addresses:");\r
-                IPAddress[] list = h.AddressList;\r
-                for(int i = 0; i < list.Length; ++i)\r
-                        Console.WriteLine(list[i]);\r
-                Console.WriteLine("Aliases:");\r
-                string[] aliases = h.Aliases;\r
-                for(int i = 0; i < aliases.Length; ++i)\r
-                        Console.WriteLine(aliases[i]);\r
-                Console.WriteLine("----------------------------------------------------");\r
-        }\r
-*/\r
-}\r
+                       IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);\r
+                       IPHostEntry entry = Dns.EndResolve (async);\r
+                       SubTestValidIPHostEntry (entry);\r
+                       Assert.AreEqual (site1Dot, entry.AddressList [0].ToString ());\r
+               }\r
+\r
+               void ResolveCallback (IAsyncResult ar)\r
+               {\r
+                       IPHostEntry h = Dns.EndResolve (ar);\r
+                       SubTestValidIPHostEntry (h);\r
+               }\r
+\r
+#if NET_2_0\r
+               [Test]\r
+               public void BeginGetHostAddresses_HostNameOrAddress_Null ()\r
+               {\r
+                       try {\r
+                               Dns.BeginGetHostAddresses (\r
+                                       (string) null,\r
+                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("hostName", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void BeginGetHostAddresses_HostNameOrAddress_UnspecifiedAddress ()\r
+               {\r
+                       // IPv4\r
+                       try {\r
+                               Dns.BeginGetHostAddresses (\r
+                                       "0.0.0.0",\r
+                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       null);\r
+                               Assert.Fail ("#A1");\r
+                       } catch (ArgumentException ex) {\r
+                               // IPv4 address 0.0.0.0 and IPv6 address ::0 are\r
+                               // unspecified addresses that cannot be used as\r
+                               // a target address\r
+                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");\r
+                               Assert.IsNull (ex.InnerException, "#A3");\r
+                               Assert.IsNotNull (ex.Message, "#A4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#A5");\r
+                       }\r
+\r
+                       // IPv6\r
+                       try {\r
+                               Dns.BeginGetHostAddresses (\r
+                                       "::0",\r
+                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       null);\r
+                               Assert.Fail ("#B1");\r
+                       } catch (ArgumentException ex) {\r
+                               // IPv4 address 0.0.0.0 and IPv6 address ::0 are\r
+                               // unspecified addresses that cannot be used as\r
+                               // a target address\r
+                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");\r
+                               Assert.IsNull (ex.InnerException, "#B3");\r
+                               Assert.IsNotNull (ex.Message, "#B4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#B5");\r
+                       }\r
+               }\r
+\r
+               void GetHostAddressesCallback (IAsyncResult ar)\r
+               {\r
+                       IPAddress [] addresses = Dns.EndGetHostAddresses (ar);\r
+                       Assert.IsNotNull (addresses);\r
+               }\r
+\r
+               [Test]\r
+               public void GetHostAddresses_HostNameOrAddress_Null ()\r
+               {\r
+                       try {\r
+                               Dns.GetHostAddresses ((string) null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void GetHostAddresses_HostNameOrAddress_UnspecifiedAddress ()\r
+               {\r
+                       // IPv4\r
+                       try {\r
+                               Dns.GetHostAddresses ("0.0.0.0");\r
+                               Assert.Fail ("#A1");\r
+                       } catch (ArgumentException ex) {\r
+                               // IPv4 address 0.0.0.0 and IPv6 address ::0 are\r
+                               // unspecified addresses that cannot be used as\r
+                               // a target address\r
+                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");\r
+                               Assert.IsNull (ex.InnerException, "#A3");\r
+                               Assert.IsNotNull (ex.Message, "#A4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#A5");\r
+                       }\r
+\r
+                       // IPv6\r
+                       try {\r
+                               Dns.GetHostAddresses ("::0");\r
+                               Assert.Fail ("#B1");\r
+                       } catch (ArgumentException ex) {\r
+                               // IPv4 address 0.0.0.0 and IPv6 address ::0 are\r
+                               // unspecified addresses that cannot be used as\r
+                               // a target address\r
+                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");\r
+                               Assert.IsNull (ex.InnerException, "#B3");\r
+                               Assert.IsNotNull (ex.Message, "#B4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#B5");\r
+                       }\r
+               }\r
+#endif\r
+\r
+               [Test]\r
+               public void GetHostName ()\r
+               {\r
+                       string hostName = Dns.GetHostName ();\r
+                       Assert.IsNotNull (hostName);\r
+               }\r
+\r
+               [Test]\r
+               public void GetHostByName ()\r
+               {\r
+                       SubTestGetHostByName (site1Name, site1Dot);\r
+                       SubTestGetHostByName (site2Name, site2Dot);\r
+                       try {\r
+                               Dns.GetHostByName (noneExistingSite);\r
+                               Assert.Fail ("Should raise a SocketException (assuming that '" + noneExistingSite + "' does not exist)");\r
+                       } catch (SocketException) {\r
+                       }\r
+               }\r
+\r
+               void SubTestGetHostByName (string siteName, string siteDot)\r
+               {\r
+                       IPHostEntry h = Dns.GetHostByName (siteName);\r
+                       SubTestValidIPHostEntry (h);\r
+                       Assert.AreEqual (siteName, h.HostName, "siteName");\r
+                       Assert.AreEqual (siteDot, h.AddressList [0].ToString (), "siteDot");\r
+               }\r
+\r
+               [Test]\r
+               public void GetHostByName_HostName_Null ()\r
+               {\r
+                       try {\r
+                               Dns.GetHostByName ((string) null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("hostName", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void GetHostByAddressString_Address_Null ()\r
+               {\r
+                       try {\r
+                               Dns.GetHostByAddress ((string) null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("address", ex.ParamName, "#5");\r
+                       }\r
+               }\r
 \r
+               [Test]\r
+               [ExpectedException (typeof (SocketException))]\r
+#if TARGET_JVM\r
+               [Ignore ("Ignore failures in Sys.Net")]\r
+#endif\r
+               public void GetHostByAddressString2 ()\r
+               {\r
+                       Dns.GetHostByAddress ("123.255.23");\r
+               }\r
+\r
+               [Test]\r
+               [ExpectedException (typeof (FormatException))]\r
+               public void GetHostByAddressString3 ()\r
+               {\r
+                       Dns.GetHostByAddress ("123.256.34.10");\r
+               }\r
+\r
+               [Test, ExpectedException (typeof (FormatException))]\r
+               public void GetHostByAddressString4 ()\r
+               {\r
+                       Dns.GetHostByAddress ("not an IP address");\r
+               }\r
+\r
+               [Test]\r
+/*** Current go-mono.com IP works fine here***\r
+#if ONLY_1_1\r
+               [ExpectedException (typeof (SocketException))]\r
+#endif\r
+********/\r
+               public void GetHostByAddressString5 ()\r
+               {\r
+                       Dns.GetHostByAddress (site1Dot);\r
+               }\r
+\r
+               [Test]\r
+               public void GetHostByAddressIPAddress_Address_Null ()\r
+               {\r
+                       try {\r
+                               Dns.GetHostByAddress ((IPAddress) null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("address", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void GetHostByAddressIPAddress2 ()\r
+               {\r
+                       IPAddress addr = new IPAddress (IPAddress.NetworkToHostOrder ((int) site1IP));\r
+                       IPHostEntry h = Dns.GetHostByAddress (addr);\r
+                       SubTestValidIPHostEntry (h);\r
+                       Assert.AreEqual (addr.ToString (), h.AddressList [0].ToString ());\r
+               }\r
+\r
+               [Test]\r
+               public void GetHostByAddressIPAddress3 ()\r
+               {\r
+                       IPAddress addr = new IPAddress (IPAddress.NetworkToHostOrder ((int) site2IP));\r
+                       IPHostEntry h = Dns.GetHostByAddress (addr);\r
+                       SubTestValidIPHostEntry (h);\r
+                       Assert.AreEqual (addr.ToString (), h.AddressList [0].ToString ());\r
+               }\r
+\r
+               [Test]\r
+               public void BeginResolve_HostName_Null ()\r
+               {\r
+                       try {\r
+                               Dns.BeginResolve ((string) null,\r
+                                       new AsyncCallback (ResolveCallback),\r
+                                       null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("hostName", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void Resolve ()\r
+               {\r
+                       SubTestResolve (site1Name);\r
+                       SubTestResolve (site2Name);\r
+                       SubTestResolve (site1Dot);\r
+                       SubTestResolve (site2Dot);\r
+               }\r
+\r
+               void SubTestResolve (string addr)\r
+               {\r
+                       IPHostEntry h = Dns.Resolve (addr);\r
+                       SubTestValidIPHostEntry (h);\r
+               }\r
+\r
+               [Test]\r
+               public void Resolve_HostName_Null ()\r
+               {\r
+                       try {\r
+                               Dns.Resolve ((string) null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("hostName", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+#if NET_2_0\r
+               [Test] // BeginGetHostEntry (IPAddress, AsyncCallback, Object)\r
+               public void BeginGetHostEntry1_Address_Null ()\r
+               {\r
+                       try {\r
+                               Dns.BeginGetHostEntry (\r
+                                       (IPAddress) null,\r
+                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("address", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               [Test] // BeginGetHostEntry (String, AsyncCallback, Object)\r
+               public void BeginGetHostEntry2_HostNameOrAddress_Null ()\r
+               {\r
+                       try {\r
+                               Dns.BeginGetHostEntry (\r
+                                       (string) null,\r
+                                       new AsyncCallback (GetHostAddressesCallback),\r
+                                       null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("hostName", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               [Test] // BeginGetHostEntry (String, AsyncCallback, Object)\r
+               public void BeginGetHostEntry2_HostNameOrAddress_UnspecifiedAddress ()\r
+               {\r
+                       // IPv4\r
+                       try {\r
+                               Dns.BeginGetHostEntry (\r
+                                       "0.0.0.0",\r
+                                       new AsyncCallback (GetHostEntryCallback),\r
+                                       null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentException ex) {\r
+                               // IPv4 address 0.0.0.0 and IPv6 address ::0 are\r
+                               // unspecified addresses that cannot be used as\r
+                               // a target address\r
+                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#5");\r
+                       }\r
+\r
+                       // IPv6\r
+                       try {\r
+                               Dns.BeginGetHostEntry (\r
+                                       "::0",\r
+                                       new AsyncCallback (GetHostEntryCallback),\r
+                                       null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentException ex) {\r
+                               // IPv4 address 0.0.0.0 and IPv6 address ::0 are\r
+                               // unspecified addresses that cannot be used as\r
+                               // a target address\r
+                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               void GetHostEntryCallback (IAsyncResult ar)\r
+               {\r
+                       IPHostEntry hostEntry = Dns.EndGetHostEntry (ar);\r
+                       Assert.IsNotNull (hostEntry);\r
+               }\r
+\r
+               [Test] // GetHostEntry (IPAddress)\r
+               public void GetHostEntry1_Address_Null ()\r
+               {\r
+                       try {\r
+                               Dns.GetHostEntry ((IPAddress) null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("address", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               [Test] // GetHostEntry (String)\r
+               public void GetHostEntry2 ()\r
+               {\r
+                       Dns.GetHostEntry (site1Name); // hostname\r
+                       Dns.GetHostEntry (site1Dot); // IP address\r
+               }\r
+\r
+               [Test] // GetHostEntry (String)\r
+               public void GetHostEntry2_HostNameOrAddress_Null ()\r
+               {\r
+                       try {\r
+                               Dns.GetHostEntry ((string) null);\r
+                               Assert.Fail ("#1");\r
+                       } catch (ArgumentNullException ex) {\r
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#5");\r
+                       }\r
+               }\r
+\r
+               [Test] // GetHostEntry (String)\r
+               public void GetHostEntry2_HostNameOrAddress_UnspecifiedAddress ()\r
+               {\r
+                       // IPv4\r
+                       try {\r
+                               Dns.GetHostEntry ("0.0.0.0");\r
+                               Assert.Fail ("#A1");\r
+                       } catch (ArgumentException ex) {\r
+                               // IPv4 address 0.0.0.0 and IPv6 address ::0 are\r
+                               // unspecified addresses that cannot be used as\r
+                               // a target address\r
+                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");\r
+                               Assert.IsNull (ex.InnerException, "#A3");\r
+                               Assert.IsNotNull (ex.Message, "#A4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#A5");\r
+                       }\r
+\r
+                       // IPv6\r
+                       try {\r
+                               Dns.GetHostEntry ("::0");\r
+                               Assert.Fail ("#B1");\r
+                       } catch (ArgumentException ex) {\r
+                               // IPv4 address 0.0.0.0 and IPv6 address ::0 are\r
+                               // unspecified addresses that cannot be used as\r
+                               // a target address\r
+                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");\r
+                               Assert.IsNull (ex.InnerException, "#B3");\r
+                               Assert.IsNotNull (ex.Message, "#B4");\r
+                               Assert.AreEqual ("hostNameOrAddress", ex.ParamName, "#B5");\r
+                       }\r
+               }\r
+#endif\r
+\r
+               void SubTestValidIPHostEntry (IPHostEntry h)\r
+               {\r
+                       Assert.IsNotNull (h.HostName, "HostName not null");\r
+                       Assert.IsNotNull (h.AddressList, "AddressList not null");\r
+                       Assert.IsTrue (h.AddressList.Length > 0, "AddressList.Length");\r
+               }\r
+\r
+               /* This isn't used anymore, but could be useful for debugging\r
+               static void printIPHostEntry(IPHostEntry h)\r
+               {\r
+                       Console.WriteLine("----------------------------------------------------");\r
+                       Console.WriteLine("Host name:");\r
+                       Console.WriteLine(h.HostName);\r
+                       Console.WriteLine("IP addresses:");\r
+                       IPAddress[] list = h.AddressList;\r
+                       for(int i = 0; i < list.Length; ++i)\r
+                               Console.WriteLine(list[i]);\r
+                       Console.WriteLine("Aliases:");\r
+                       string[] aliases = h.Aliases;\r
+                       for(int i = 0; i < aliases.Length; ++i)\r
+                               Console.WriteLine(aliases[i]);\r
+                       Console.WriteLine("----------------------------------------------------");\r
+               }\r
+               */\r
+       }\r
 }\r