You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
@ -29,41 +29,77 @@ namespace MonoTests.System.Net
|
||||
private uint site1IP = 134744072, site2IP = 134743044; // Big-Endian
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AsyncGetHostByName ()
|
||||
{
|
||||
IAsyncResult r;
|
||||
r = Dns.BeginGetHostByName (site1Name, new AsyncCallback (GetHostByNameCallback), null);
|
||||
|
||||
IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);
|
||||
IPHostEntry entry = Dns.EndGetHostByName (async);
|
||||
SubTestValidIPHostEntry (entry);
|
||||
Assert.IsTrue (entry.HostName == "google-public-dns-a.google.com");
|
||||
}
|
||||
|
||||
void GetHostByNameCallback (IAsyncResult ar)
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AsyncGetHostByNameCallback ()
|
||||
{
|
||||
IPHostEntry h;
|
||||
h = Dns.EndGetHostByName (ar);
|
||||
SubTestValidIPHostEntry (h);
|
||||
var evt = new ManualResetEvent (false);
|
||||
Exception ex = null;
|
||||
Dns.BeginGetHostByName (site1Name, new AsyncCallback ((IAsyncResult ar) =>
|
||||
{
|
||||
try {
|
||||
IPHostEntry h;
|
||||
h = Dns.EndGetHostByName (ar);
|
||||
SubTestValidIPHostEntry (h);
|
||||
} catch (Exception e) {
|
||||
ex = e;
|
||||
} finally {
|
||||
evt.Set ();
|
||||
}
|
||||
}), null);
|
||||
|
||||
Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");
|
||||
Assert.IsNull (ex, "Exception");
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AsyncResolve ()
|
||||
{
|
||||
IAsyncResult r;
|
||||
r = Dns.BeginResolve (site1Name, new AsyncCallback (ResolveCallback), null);
|
||||
|
||||
IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);
|
||||
IPHostEntry entry = Dns.EndResolve (async);
|
||||
SubTestValidIPHostEntry (entry);
|
||||
SubTestValidIPHostEntry (entry);
|
||||
var ip = GetIPv4Address (entry);
|
||||
Assert.AreEqual (site1Dot, ip.ToString ());
|
||||
}
|
||||
|
||||
void ResolveCallback (IAsyncResult ar)
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void AsyncResolveCallback ()
|
||||
{
|
||||
IPHostEntry h = Dns.EndResolve (ar);
|
||||
SubTestValidIPHostEntry (h);
|
||||
var evt = new ManualResetEvent (false);
|
||||
Exception ex = null;
|
||||
Dns.BeginResolve (site1Name, new AsyncCallback ((IAsyncResult ar) =>
|
||||
{
|
||||
try {
|
||||
IPHostEntry h = Dns.EndResolve (ar);
|
||||
SubTestValidIPHostEntry (h);
|
||||
} catch (Exception e) {
|
||||
ex = e;
|
||||
} finally {
|
||||
evt.Set ();
|
||||
}
|
||||
}), null);
|
||||
|
||||
Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");
|
||||
Assert.IsNull (ex, "Exception");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -72,7 +108,7 @@ namespace MonoTests.System.Net
|
||||
try {
|
||||
Dns.BeginGetHostAddresses (
|
||||
(string) null,
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#1");
|
||||
} catch (ArgumentNullException ex) {
|
||||
@ -90,7 +126,7 @@ namespace MonoTests.System.Net
|
||||
try {
|
||||
Dns.BeginGetHostAddresses (
|
||||
"0.0.0.0",
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#A1");
|
||||
} catch (ArgumentException ex) {
|
||||
@ -107,7 +143,7 @@ namespace MonoTests.System.Net
|
||||
try {
|
||||
Dns.BeginGetHostAddresses (
|
||||
"::0",
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#B1");
|
||||
} catch (ArgumentException ex) {
|
||||
@ -121,10 +157,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
}
|
||||
|
||||
void GetHostAddressesCallback (IAsyncResult ar)
|
||||
void ShouldntBeCalled (IAsyncResult ar)
|
||||
{
|
||||
IPAddress [] addresses = Dns.EndGetHostAddresses (ar);
|
||||
Assert.IsNotNull (addresses);
|
||||
Assert.Fail ("Should not be called");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -181,6 +216,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void GetHostByName ()
|
||||
{
|
||||
SubTestGetHostByName (site1Name, site1Dot);
|
||||
@ -306,17 +344,20 @@ namespace MonoTests.System.Net
|
||||
{
|
||||
IPAddress addr = new IPAddress (IPAddress.NetworkToHostOrder ((int) site2IP));
|
||||
IPHostEntry h = Dns.GetHostByAddress (addr);
|
||||
SubTestValidIPHostEntry (h);
|
||||
SubTestValidIPHostEntry (h);
|
||||
var ip = GetIPv4Address (h);
|
||||
Assert.AreEqual (addr.ToString (), ip.ToString ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginResolve_HostName_Null ()
|
||||
{
|
||||
try {
|
||||
Dns.BeginResolve ((string) null,
|
||||
new AsyncCallback (ResolveCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#1");
|
||||
} catch (ArgumentNullException ex) {
|
||||
@ -328,6 +369,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Resolve ()
|
||||
{
|
||||
SubTestResolve (site1Name);
|
||||
@ -343,6 +387,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void Resolve_HostName_Null ()
|
||||
{
|
||||
try {
|
||||
@ -357,12 +404,15 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // BeginGetHostEntry (IPAddress, AsyncCallback, Object)
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginGetHostEntry1_Address_Null ()
|
||||
{
|
||||
try {
|
||||
Dns.BeginGetHostEntry (
|
||||
(IPAddress) null,
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#1");
|
||||
} catch (ArgumentNullException ex) {
|
||||
@ -374,12 +424,15 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // BeginGetHostEntry (String, AsyncCallback, Object)
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginGetHostEntry2_HostNameOrAddress_Null ()
|
||||
{
|
||||
try {
|
||||
Dns.BeginGetHostEntry (
|
||||
(string) null,
|
||||
new AsyncCallback (GetHostAddressesCallback),
|
||||
new AsyncCallback (ShouldntBeCalled),
|
||||
null);
|
||||
Assert.Fail ("#1");
|
||||
} catch (ArgumentNullException ex) {
|
||||
@ -391,6 +444,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // BeginGetHostEntry (String, AsyncCallback, Object)
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void BeginGetHostEntry2_HostNameOrAddress_UnspecifiedAddress ()
|
||||
{
|
||||
// IPv4
|
||||
@ -449,6 +505,9 @@ namespace MonoTests.System.Net
|
||||
}
|
||||
|
||||
[Test] // GetHostEntry (String)
|
||||
#if FEATURE_NO_BSD_SOCKETS
|
||||
[ExpectedException (typeof (PlatformNotSupportedException))]
|
||||
#endif
|
||||
public void GetHostEntry2 ()
|
||||
{
|
||||
Dns.GetHostEntry (site1Name); // hostname
|
||||
|
Reference in New Issue
Block a user