You've already forked linux-packaging-mono
Imported Upstream version 4.0.0~alpha1
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
@ -0,0 +1,77 @@
|
||||
//
|
||||
// IPInterfacePropertiesTest.cs - NUnit Test Cases for System.Net.NetworkInformation.IPInterfaceProperties
|
||||
//
|
||||
// Authors:
|
||||
// Ben Woods (woodsb02@gmail.com)
|
||||
//
|
||||
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace MonoTests.System.Net.NetworkInformation
|
||||
{
|
||||
|
||||
[TestFixture]
|
||||
public class IPInterfacePropertiesTest
|
||||
{
|
||||
[Test]
|
||||
public void AtLeastOneUnicastAddress ()
|
||||
{
|
||||
int numUnicastAddresses = 0;
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
|
||||
foreach (NetworkInterface adapter in adapters)
|
||||
{
|
||||
IPInterfaceProperties adapterProperties = adapter.GetIPProperties ();
|
||||
UnicastIPAddressInformationCollection unicastAddresses = adapterProperties.UnicastAddresses;
|
||||
numUnicastAddresses += unicastAddresses.Count;
|
||||
}
|
||||
Assert.IsTrue (numUnicastAddresses > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AtLeastOneGatewayAddress ()
|
||||
{
|
||||
int numGatewayAddresses = 0;
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
|
||||
foreach (NetworkInterface adapter in adapters)
|
||||
{
|
||||
IPInterfaceProperties adapterProperties = adapter.GetIPProperties ();
|
||||
GatewayIPAddressInformationCollection gatewayAddresses = adapterProperties.GatewayAddresses;
|
||||
numGatewayAddresses += gatewayAddresses.Count;
|
||||
}
|
||||
Assert.IsTrue (numGatewayAddresses > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DnsEnabled ()
|
||||
{
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
|
||||
foreach (NetworkInterface adapter in adapters)
|
||||
{
|
||||
IPInterfaceProperties adapterProperties = adapter.GetIPProperties ();
|
||||
Assert.IsTrue (adapterProperties.IsDnsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AtLeastOneDnsAddress ()
|
||||
{
|
||||
int numDnsAddresses = 0;
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
|
||||
foreach (NetworkInterface adapter in adapters)
|
||||
{
|
||||
IPInterfaceProperties adapterProperties = adapter.GetIPProperties ();
|
||||
IPAddressCollection dnsAddresses = adapterProperties.DnsAddresses;
|
||||
numDnsAddresses += dnsAddresses.Count;
|
||||
}
|
||||
// reading /etc/resolve.conf does not work on iOS devices (but works on simulator)
|
||||
// ref: https://bugzilla.xamarin.com/show_bug.cgi?id=27707
|
||||
#if !MONOTOUCH
|
||||
Assert.IsTrue (numDnsAddresses > 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
//
|
||||
// NetworkInterfaceTest.cs - NUnit Test Cases for System.Net.NetworkInformation.NetworkInterface
|
||||
//
|
||||
// Authors:
|
||||
// Ben Woods (woodsb02@gmail.com)
|
||||
//
|
||||
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace MonoTests.System.Net.NetworkInformation
|
||||
{
|
||||
|
||||
[TestFixture]
|
||||
public class NetworkInterfaceTest
|
||||
{
|
||||
[Test]
|
||||
public void IsNetworkAvailable ()
|
||||
{
|
||||
Assert.IsTrue (NetworkInterface.GetIsNetworkAvailable ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoopbackInterfaceIndex ()
|
||||
{
|
||||
Assert.IsTrue (NetworkInterface.LoopbackInterfaceIndex > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AtLeastOneInterface ()
|
||||
{
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
|
||||
Assert.IsTrue (adapters.Length > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FirstInterfaceId ()
|
||||
{
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
|
||||
Assert.IsTrue (adapters[0].Id.Length > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FirstInterfaceName ()
|
||||
{
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
|
||||
Assert.IsTrue (adapters[0].Name.Length > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FirstInterfaceType ()
|
||||
{
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
|
||||
Assert.AreNotEqual (adapters[0].NetworkInterfaceType, NetworkInterfaceType.Unknown);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FirstInterfaceOperationalStatus ()
|
||||
{
|
||||
var adapter = NetworkInterface.GetAllNetworkInterfaces ()[0];
|
||||
var status = adapter.OperationalStatus;
|
||||
// lo status is Unknown on Linux
|
||||
//Assert.AreNotEqual (adapter.OperationalStatus, OperationalStatus.Unknown);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FirstInterfaceSpeed ()
|
||||
{
|
||||
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces ();
|
||||
Assert.IsTrue (adapters[0].Speed > 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
#if NET_2_0
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace MonoTests.System.Net.NetworkInformation
|
||||
@ -133,4 +132,3 @@ namespace MonoTests.System.Net.NetworkInformation
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,33 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace MonoTests.System.Net.NetworkInformation
|
||||
{
|
||||
[TestFixture]
|
||||
public class PingTest
|
||||
{
|
||||
[Test]
|
||||
public void PingFail()
|
||||
{
|
||||
#if MONOTOUCH
|
||||
Assert.Ignore ("Ping implementation is broken on MT (requires sudo access)");
|
||||
#else
|
||||
var p = new Ping ().Send ("192.0.2.0");
|
||||
Assert.AreNotEqual(IPStatus.Success, p.Status);
|
||||
#endif
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PingSuccess()
|
||||
{
|
||||
#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);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user