You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -1,13 +1,17 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
|
||||
namespace MonoTests.System.Net.NetworkInformation
|
||||
{
|
||||
[TestFixture]
|
||||
public class PingTest
|
||||
public partial class PingTest
|
||||
{
|
||||
[Test]
|
||||
partial void AndroidShouldPingWork (ref bool shouldWork);
|
||||
|
||||
[Test]
|
||||
public void PingFail()
|
||||
{
|
||||
#if MONOTOUCH
|
||||
@ -24,10 +28,99 @@ namespace MonoTests.System.Net.NetworkInformation
|
||||
#if MONOTOUCH
|
||||
Assert.Ignore ("Ping implementation is broken on MT (requires sudo access)");
|
||||
#else
|
||||
var p = new Ping ().Send ("127.0.0.1");
|
||||
Assert.AreEqual(IPStatus.Success, p.Status);
|
||||
bool shouldWork = true;
|
||||
AndroidShouldPingWork (ref shouldWork);
|
||||
if (shouldWork) {
|
||||
var p = new Ping ().Send ("127.0.0.1");
|
||||
Assert.AreEqual(IPStatus.Success, p.Status);
|
||||
} else
|
||||
Assert.Ignore ("Ping will not work on this Android device");
|
||||
#endif
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if MONOTOUCH
|
||||
[Ignore("Ping implementation is broken on MT (requires sudo access)")]
|
||||
#endif
|
||||
public void SendAsyncIPV4Succeeds()
|
||||
{
|
||||
var testIp = IPAddress.Loopback;
|
||||
var ping = new Ping ();
|
||||
PingReply reply = null;
|
||||
|
||||
using (var waiter = new AutoResetEvent (false)) {
|
||||
ping.PingCompleted += new PingCompletedEventHandler (
|
||||
(s, e) => {
|
||||
reply = e.Reply;
|
||||
(e.UserState as AutoResetEvent) ?.Set ();
|
||||
});
|
||||
|
||||
ping.SendAsync (testIp, waiter);
|
||||
|
||||
waiter.WaitOne (TimeSpan.FromSeconds (8));
|
||||
}
|
||||
|
||||
Assert.AreEqual (IPStatus.Success, reply.Status);
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if MONOTOUCH
|
||||
[Ignore("Ping implementation is broken on MT (requires sudo access)")]
|
||||
#endif
|
||||
public void SendAsyncIPV4Fails()
|
||||
{
|
||||
var testIp = IPAddress.Parse("192.0.2.0");
|
||||
var ping = new Ping ();
|
||||
PingReply reply = null;
|
||||
|
||||
using (var waiter = new AutoResetEvent (false)) {
|
||||
ping.PingCompleted += new PingCompletedEventHandler (
|
||||
(s, e) => {
|
||||
reply = e.Reply;
|
||||
(e.UserState as AutoResetEvent) ?.Set ();
|
||||
});
|
||||
|
||||
ping.SendAsync (testIp, waiter);
|
||||
|
||||
waiter.WaitOne (TimeSpan.FromSeconds (8));
|
||||
}
|
||||
|
||||
Assert.AreNotEqual (IPStatus.Success, reply.Status);
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if MONOTOUCH
|
||||
[Ignore("Ping implementation is broken on MT (requires sudo access)")]
|
||||
#endif
|
||||
public void SendPingAsyncIPV4Succeeds()
|
||||
{
|
||||
var testIp = IPAddress.Loopback;
|
||||
var ping = new Ping ();
|
||||
var task = ping.SendPingAsync (testIp);
|
||||
|
||||
task.Wait();
|
||||
|
||||
var result = task.Result;
|
||||
|
||||
Assert.AreEqual (IPStatus.Success, result.Status);
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if MONOTOUCH
|
||||
[Ignore("Ping implementation is broken on MT (requires sudo access)")]
|
||||
#endif
|
||||
public void SendPingAsyncIPV4Fails()
|
||||
{
|
||||
var testIp = IPAddress.Parse("192.0.2.0");
|
||||
var ping = new Ping ();
|
||||
var task = ping.SendPingAsync (testIp);
|
||||
|
||||
task.Wait();
|
||||
|
||||
var result = task.Result;
|
||||
|
||||
Assert.AreNotEqual (IPStatus.Success, result.Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user