private uint site1IP = 134744072, site2IP = 134743044; // Big-Endian\r
\r
[Test]\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void AsyncGetHostByName ()\r
{\r
- IAsyncResult r;\r
- r = Dns.BeginGetHostByName (site1Name, new AsyncCallback (GetHostByNameCallback), null);\r
-\r
IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);\r
IPHostEntry entry = Dns.EndGetHostByName (async);\r
SubTestValidIPHostEntry (entry);\r
Assert.IsTrue (entry.HostName == "google-public-dns-a.google.com");\r
}\r
\r
- void GetHostByNameCallback (IAsyncResult ar)\r
- {\r
- IPHostEntry h;\r
- h = Dns.EndGetHostByName (ar);\r
- SubTestValidIPHostEntry (h);\r
+ [Test]\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
+ public void AsyncGetHostByNameCallback ()\r
+ {\r
+ var evt = new ManualResetEvent (false);\r
+ Exception ex = null;\r
+ Dns.BeginGetHostByName (site1Name, new AsyncCallback ((IAsyncResult ar) =>\r
+ {\r
+ try {\r
+ IPHostEntry h;\r
+ h = Dns.EndGetHostByName (ar);\r
+ SubTestValidIPHostEntry (h);\r
+ } catch (Exception e) {\r
+ ex = e;\r
+ } finally {\r
+ evt.Set ();\r
+ }\r
+ }), null);\r
+\r
+ Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");\r
+ Assert.IsNull (ex, "Exception");\r
}\r
\r
[Test]\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void AsyncResolve ()\r
{\r
- IAsyncResult r;\r
- r = Dns.BeginResolve (site1Name, new AsyncCallback (ResolveCallback), null);\r
-\r
IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);\r
IPHostEntry entry = Dns.EndResolve (async);\r
- SubTestValidIPHostEntry (entry);
+ SubTestValidIPHostEntry (entry);\r
var ip = GetIPv4Address (entry);\r
Assert.AreEqual (site1Dot, ip.ToString ());\r
}\r
\r
- void ResolveCallback (IAsyncResult ar)\r
- {\r
- IPHostEntry h = Dns.EndResolve (ar);\r
- SubTestValidIPHostEntry (h);\r
+ [Test]\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
+ public void AsyncResolveCallback ()\r
+ {\r
+ var evt = new ManualResetEvent (false);\r
+ Exception ex = null;\r
+ Dns.BeginResolve (site1Name, new AsyncCallback ((IAsyncResult ar) =>\r
+ {\r
+ try {\r
+ IPHostEntry h = Dns.EndResolve (ar);\r
+ SubTestValidIPHostEntry (h);\r
+ } catch (Exception e) {\r
+ ex = e;\r
+ } finally {\r
+ evt.Set ();\r
+ }\r
+ }), null);\r
+\r
+ Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");\r
+ Assert.IsNull (ex, "Exception");\r
}\r
\r
[Test]\r
try {\r
Dns.BeginGetHostAddresses (\r
(string) null,\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#1");\r
} catch (ArgumentNullException ex) {\r
try {\r
Dns.BeginGetHostAddresses (\r
"0.0.0.0",\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#A1");\r
} catch (ArgumentException ex) {\r
try {\r
Dns.BeginGetHostAddresses (\r
"::0",\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#B1");\r
} catch (ArgumentException ex) {\r
}\r
}\r
\r
- void GetHostAddressesCallback (IAsyncResult ar)\r
+ void ShouldntBeCalled (IAsyncResult ar)\r
{\r
- IPAddress [] addresses = Dns.EndGetHostAddresses (ar);\r
- Assert.IsNotNull (addresses);\r
+ Assert.Fail ("Should not be called");\r
}\r
\r
[Test]\r
}\r
\r
[Test]\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void GetHostByName ()\r
{\r
SubTestGetHostByName (site1Name, site1Dot);\r
{\r
IPAddress addr = new IPAddress (IPAddress.NetworkToHostOrder ((int) site2IP));\r
IPHostEntry h = Dns.GetHostByAddress (addr);\r
- SubTestValidIPHostEntry (h);
+ SubTestValidIPHostEntry (h);\r
var ip = GetIPv4Address (h);\r
Assert.AreEqual (addr.ToString (), ip.ToString ());\r
}\r
\r
[Test]\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void BeginResolve_HostName_Null ()\r
{\r
try {\r
Dns.BeginResolve ((string) null,\r
- new AsyncCallback (ResolveCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#1");\r
} catch (ArgumentNullException ex) {\r
}\r
\r
[Test]\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void Resolve ()\r
{\r
SubTestResolve (site1Name);\r
}\r
\r
[Test]\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void Resolve_HostName_Null ()\r
{\r
try {\r
}\r
\r
[Test] // BeginGetHostEntry (IPAddress, AsyncCallback, Object)\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void BeginGetHostEntry1_Address_Null ()\r
{\r
try {\r
Dns.BeginGetHostEntry (\r
(IPAddress) null,\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#1");\r
} catch (ArgumentNullException ex) {\r
}\r
\r
[Test] // BeginGetHostEntry (String, AsyncCallback, Object)\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void BeginGetHostEntry2_HostNameOrAddress_Null ()\r
{\r
try {\r
Dns.BeginGetHostEntry (\r
(string) null,\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#1");\r
} catch (ArgumentNullException ex) {\r
}\r
\r
[Test] // BeginGetHostEntry (String, AsyncCallback, Object)\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void BeginGetHostEntry2_HostNameOrAddress_UnspecifiedAddress ()\r
{\r
// IPv4\r
}\r
\r
[Test] // GetHostEntry (String)\r
+#if FEATURE_NO_BSD_SOCKETS\r
+ [ExpectedException (typeof (PlatformNotSupportedException))]\r
+#endif\r
public void GetHostEntry2 ()\r
{\r
Dns.GetHostEntry (site1Name); // hostname\r