Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -190,7 +190,7 @@ namespace MonoTests.System.ComponentModel.Design.Serialization {
{
#if MOBILE
// ensure the property is not linked out of the application since it make the test fails
Assert.NotNull (Thread.CurrentPrincipal, "pre-test");
Assert.IsNotNull (Thread.CurrentPrincipal, "pre-test");
#endif
PropertyInfo pi = typeof (Thread).GetProperty ("CurrentPrincipal");
@@ -213,7 +213,7 @@ namespace MonoTests.System.ComponentModel.Design.Serialization {
{
#if MOBILE
// ensure the property is not linked out of the application since it make the test fails
Assert.NotNull (Thread.CurrentPrincipal, "pre-test");
Assert.IsNotNull (Thread.CurrentPrincipal, "pre-test");
#endif
PropertyInfo pi = typeof (Thread).GetProperty ("CurrentPrincipal");

View File

@@ -47,7 +47,7 @@ namespace MonoTests.System.ComponentModel {
Assert.AreEqual(CM.CategoryAttribute.Key.Category, "Key", "#9");
Assert.AreEqual(CM.CategoryAttribute.Layout.Category, "Layout", "#10");
Assert.AreEqual(CM.CategoryAttribute.Mouse.Category, "Mouse", "#11");
#if NET_2_1
#if MOBILE
Assert.AreEqual(CM.CategoryAttribute.Default.Category, "Default", "#12");
Assert.AreEqual(CM.CategoryAttribute.DragDrop.Category, "DragDrop", "#13");
Assert.AreEqual(CM.CategoryAttribute.WindowStyle.Category, "WindowStyle", "#14");

View File

@@ -1 +1 @@
668e863b5cc055feed1a132c8bc42e8fb00e586f
b747e0dd0164e0fc6e98da731bc02b49911c94ef

View File

@@ -1084,6 +1084,27 @@ namespace MonoTests.System.Diagnostics
Assert.Fail ();
}
}
[Test]
[NUnit.Framework.Category ("MobileNotWorking")]
public void TestExitedRaisedTooSoon ()
{
if (!RunningOnUnix)
Assert.Ignore ("using sleep command, only available on unix");
int sleeptime = 5;
using (Process p = Process.Start("sleep", sleeptime.ToString ())) {
ManualResetEvent mre = new ManualResetEvent (false);
p.EnableRaisingEvents = true;
p.Exited += (sender, e) => {
mre.Set ();
};
Assert.IsFalse (mre.WaitOne ((sleeptime - 2) * 1000), "Exited triggered before the process returned");
}
}
#endif // MONO_FEATURE_PROCESS_START
}
}

View File

@@ -343,7 +343,6 @@ namespace MonoTests.System.IO.Compression
return new MemoryStream (Encoding.UTF8.GetBytes (s));
}
#if NET_4_5
[Test]
public void CheckNet45Overloads () // Xambug #21982
{
@@ -361,7 +360,6 @@ namespace MonoTests.System.IO.Compression
decompressing.Close();
backing.Close();
}
#endif
[Test]
[ExpectedException (typeof (ArgumentException))]
@@ -412,6 +410,46 @@ namespace MonoTests.System.IO.Compression
using (var unZippedStream = new StreamReader (gZipStream, Encoding.UTF8)) {
unZipped = unZippedStream.ReadToEnd ();
}
Assert.AreEqual(1877, unZipped.Length);
}
[Test]
public void Bug44994_Inflate()
{
var base64String = @"7cWxCQAgDACwpeBjgqsgXiHU0fd9QzBLErX1EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADepcxcuU/atm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm37zy8=";
byte[] byteArray = Convert.FromBase64String(base64String);
string unZipped = null;
using (var zippedMemoryStream = new MemoryStream(byteArray))
using (var gZipStream = new DeflateStream(zippedMemoryStream, CompressionMode.Decompress))
using (var unzippedMemStream = new MemoryStream())
using (var unZippedStream = new StreamReader(gZipStream, Encoding.UTF8))
{
unZipped = unZippedStream.ReadToEnd();
}
Assert.AreEqual(81942, unZipped.Length);
}
[Test]
[Category ("MobileNotWorking")]
public void Bug44994_InflateByteByByte()
{
int byteCount = 0;
using (var fileStream = File.OpenRead(Path.Combine("Test", "compressed.bin")))
{
using (var deflateStream = new DeflateStream(fileStream, CompressionMode.Decompress, false))
{
while (deflateStream.ReadByte() != -1)
{
byteCount++;
}
}
}
Assert.AreEqual(125387, byteCount);
}
}
}

View File

@@ -303,7 +303,6 @@ namespace MonoTests.System.IO.Compression
return new MemoryStream (Encoding.UTF8.GetBytes (s));
}
#if NET_4_5
[Test]
public void CheckNet45Overloads () // Xambug #21982
{
@@ -321,7 +320,6 @@ namespace MonoTests.System.IO.Compression
decompressing.Close();
backing.Close();
}
#endif
}
}

View File

@@ -18,13 +18,13 @@ namespace MonoTests.System.Net.Mail
[TestFixture]
public class SmtpClientTest
{
SmtpClient smtp;
SmtpClient _smtp;
SmtpClient smtp { get { return _smtp ?? (_smtp = new SmtpClient ()); } }
string tempFolder;
[SetUp]
public void GetReady ()
{
smtp = new SmtpClient ();
tempFolder = Path.Combine (Path.GetTempPath (), this.GetType ().FullName);
if (Directory.Exists (tempFolder))
Directory.Delete (tempFolder, true);
@@ -34,17 +34,24 @@ namespace MonoTests.System.Net.Mail
[TearDown]
public void TearDown ()
{
_smtp = null;
if (Directory.Exists (tempFolder))
Directory.Delete (tempFolder, true);
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Credentials_Default ()
{
Assert.IsNull (smtp.Credentials);
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void DeliveryMethod ()
{
Assert.AreEqual (SmtpDeliveryMethod.Network, smtp.DeliveryMethod, "#1");
@@ -60,6 +67,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void EnableSsl ()
{
Assert.IsFalse (smtp.EnableSsl, "#1");
@@ -70,6 +80,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Host ()
{
smtp.Host = "127.0.0.1";
@@ -86,6 +99,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Host_Value_Null ()
{
try {
@@ -100,6 +116,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Host_Value_Empty ()
{
try {
@@ -115,6 +134,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void PickupDirectoryLocation ()
{
Assert.IsNull (smtp.PickupDirectoryLocation, "#1");
@@ -131,6 +153,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Port ()
{
Assert.AreEqual (25, smtp.Port, "#1");
@@ -141,6 +166,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Port_Value_Invalid ()
{
// zero
@@ -167,6 +195,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Send_Message_Null ()
{
try {
@@ -181,6 +212,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Send_Network_Host_Null ()
{
try {
@@ -196,6 +230,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Send_Network_Host_Whitespace ()
{
smtp.Host = " \r\n ";
@@ -212,6 +249,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Send_SpecifiedPickupDirectory ()
{
smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -225,6 +265,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_DirectoryNotFound ()
{
Directory.Delete (tempFolder);
@@ -252,6 +295,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_Empty ()
{
smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -271,6 +317,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_IllegalChars ()
{
smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -296,6 +345,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_NotAbsolute ()
{
smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -315,6 +367,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_Null ()
{
smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
@@ -333,6 +388,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Timeout ()
{
Assert.AreEqual (100000, smtp.Timeout, "#1");
@@ -343,19 +401,29 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (ArgumentOutOfRangeException))]
#endif
public void Timeout_Value_Negative ()
{
smtp.Timeout = -1;
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void UseDefaultCredentials_Default ()
{
Assert.IsFalse (smtp.UseDefaultCredentials);
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Deliver ()
{
var server = new SmtpServer ();
@@ -372,6 +440,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Deliver_Envelope ()
{
var server = new SmtpServer ();
@@ -390,6 +461,9 @@ namespace MonoTests.System.Net.Mail
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Deliver_Async ()
{
// SmtpClient uses BackgroundWorker and listens for the RunWorkerCompleted

View File

@@ -59,6 +59,9 @@ public class SslStreamTest {
}
[Test] //bug https://bugzilla.novell.com/show_bug.cgi?id=457120
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void AuthenticateClientAndServer_ClientSendsNoData ()
{
AuthenticateClientAndServer (true, true);

View File

@@ -20,7 +20,12 @@ namespace MonoTests.System.Net.Sockets
{
[Test]
// See bug #371923
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException(typeof(IOException))]
#endif
public void NetworkStreamConnection ()
{
IPEndPoint ipe = new IPEndPoint(Dns.GetHostEntry ("www.google.com").AddressList [0], 80);
@@ -30,6 +35,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ReadTimeout ()
{
Socket sock = new Socket (AddressFamily.InterNetwork,

View File

@@ -1,3 +1,4 @@
using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
@@ -9,6 +10,9 @@ namespace MonoTests.System.Net.Sockets
public class SocketAcceptAsyncTest
{
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void AcceptAsyncShouldUseAcceptSocketFromEventArgs()
{
var readyEvent = new ManualResetEvent(false);
@@ -18,27 +22,40 @@ namespace MonoTests.System.Net.Sockets
var serverSocket = new Socket(
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Socket acceptedSocket = null;
Exception ex = null;
ThreadPool.QueueUserWorkItem(_ =>
{
listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
listenSocket.Listen(1);
SocketAsyncEventArgs asyncEventArgs;
try {
listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
listenSocket.Listen(1);
var asyncEventArgs = new SocketAsyncEventArgs {AcceptSocket = serverSocket};
asyncEventArgs.Completed += (s, e) =>
{
acceptedSocket = e.AcceptSocket;
mainEvent.Set();
};
asyncEventArgs = new SocketAsyncEventArgs {AcceptSocket = serverSocket};
asyncEventArgs.Completed += (s, e) =>
{
acceptedSocket = e.AcceptSocket;
mainEvent.Set();
};
readyEvent.Set();
if (listenSocket.AcceptAsync(asyncEventArgs))
} catch (Exception e) {
ex = e;
return;
acceptedSocket = asyncEventArgs.AcceptSocket;
mainEvent.Set();
} finally {
readyEvent.Set();
}
try {
if (listenSocket.AcceptAsync(asyncEventArgs))
return;
acceptedSocket = asyncEventArgs.AcceptSocket;
mainEvent.Set();
} catch (Exception e) {
ex = e;
}
});
Assert.IsTrue(readyEvent.WaitOne(1500));
if (ex != null)
throw ex;
var clientSocket = new Socket(
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

View File

@@ -16,8 +16,7 @@ namespace MonoTests.System.Net.Sockets
ManualResetEvent mainEvent;
Exception error;
[TestFixtureSetUp]
public void SetUp ()
void SetUp ()
{
readyEvent = new ManualResetEvent (false);
mainEvent = new ManualResetEvent (false);
@@ -25,6 +24,9 @@ namespace MonoTests.System.Net.Sockets
ThreadPool.QueueUserWorkItem (_ => DoWork ());
readyEvent.WaitOne ();
if (error != null)
throw error;
clientSocket = new Socket (
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
clientSocket.Connect (serverSocket.LocalEndPoint);
@@ -42,18 +44,22 @@ namespace MonoTests.System.Net.Sockets
void DoWork ()
{
serverSocket = new Socket (
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
serverSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
serverSocket.Listen (1);
try {
serverSocket = new Socket (
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
serverSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
serverSocket.Listen (1);
var async = new SocketAsyncEventArgs ();
async.Completed += (s,e) => OnAccepted (e);
var async = new SocketAsyncEventArgs ();
async.Completed += (s,e) => OnAccepted (e);
readyEvent.Set ();
if (!serverSocket.AcceptAsync (async))
OnAccepted (async);
if (!serverSocket.AcceptAsync (async))
OnAccepted (async);
} catch (Exception e) {
error = e;
} finally {
readyEvent.Set ();
}
}
void OnAccepted (SocketAsyncEventArgs e)
@@ -92,8 +98,12 @@ namespace MonoTests.System.Net.Sockets
[Test]
[Category("Test")]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void SendAsync ()
{
SetUp ();
var buffer = new byte [] { 0x12, 0x34, 0x56, 0x78 };
var m = new ManualResetEvent (false);
var e = new SocketAsyncEventArgs ();

View File

@@ -1 +1 @@
7d024238d081e85b535a28cb160e824d94975df7
14ec2700869c289ee1159851c5402e07138b70a5

View File

@@ -29,6 +29,9 @@ namespace MonoTests.System.Net.Sockets
/// (from System.Net.Sockets)
/// </summary>
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TcpClient()
{
// set up a listening Socket
@@ -76,6 +79,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test] // bug #81105
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void CloseTest ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -139,7 +145,11 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof(ArgumentNullException))]
#endif
public void ConnectMultiNull ()
{
TcpClient client = new TcpClient ();
@@ -149,6 +159,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ConnectMultiAny ()
{
TcpClient client = new TcpClient ();
@@ -167,6 +180,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ConnectMultiRefused ()
{
TcpClient client = new TcpClient ();

View File

@@ -23,6 +23,9 @@ namespace MonoTests.System.Net.Sockets
public class TcpListenerTest
{
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TcpListener ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -74,6 +77,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void CtorInt1 ()
{
int nex = 0;
@@ -86,21 +92,33 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (ArgumentNullException))]
#endif
public void CtorIPEndPoint ()
{
new TcpListener (null);
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (ArgumentNullException))]
#endif
public void CtorIPAddressInt1 ()
{
new TcpListener (null, 100000);
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (ArgumentOutOfRangeException))]
#endif
public void CtorIPAddressInt2 ()
{
new TcpListener (IPAddress.Any, 100000);
@@ -124,6 +142,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void PreStartStatus ()
{
MyListener listener = new MyListener ();
@@ -151,6 +172,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void PostStartStatus ()
{
MyListener listener = new MyListener ();
@@ -172,6 +196,9 @@ namespace MonoTests.System.Net.Sockets
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void StartListenMoreThan5 ()
{
var port = NetworkHelpers.FindFreePort ();

View File

@@ -17,6 +17,9 @@ namespace MonoTests.System.Net.Sockets {
[TestFixture]
public class UdpClientTest {
[Test] // .ctor ()
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor1 ()
{
MyUdpClient client;
@@ -42,6 +45,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor2 ()
{
MyUdpClient client;
@@ -87,6 +93,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor2_Family_Invalid ()
{
try {
@@ -113,6 +122,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor3 ()
{
Socket s;
@@ -162,6 +174,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor3_Port_OutOfRange ()
{
try {
@@ -188,6 +203,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (IPEndPoint)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor4 ()
{
Socket s;
@@ -220,6 +238,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (IPEndPoint)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor4_LocalEP_Null ()
{
try {
@@ -234,6 +255,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32, AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor5 ()
{
Socket s;
@@ -287,6 +311,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32, AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor5_Family_Invalid ()
{
try {
@@ -317,6 +344,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (Int32, AddressFamily)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor5_Port_OutOfRange ()
{
try {
@@ -343,6 +373,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (String, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor6 ()
{
Socket s;
@@ -393,6 +426,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (String, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor6_HostName_Null ()
{
try {
@@ -407,6 +443,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // .ctor (String, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Constructor6_Port_OutOfRange ()
{
try {
@@ -433,6 +472,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void UdpClientBroadcastTest ()
{
UdpClient client = new UdpClient ();
@@ -446,6 +488,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup1_IPv4 ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -456,6 +501,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup1_IPv6 ()
{
if (!Socket.OSSupportsIPv6)
@@ -469,6 +517,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup1_MulticastAddr_Null ()
{
using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -485,6 +536,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup1_Socket_Closed ()
{
IPAddress mcast_addr = null;
@@ -527,6 +581,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (In32, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup2_IPv4 ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -549,6 +606,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (In32, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup2_IPv6 ()
{
if (!Socket.OSSupportsIPv6)
@@ -562,6 +622,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (Int32, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup2_MulticastAddr_Null ()
{
using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -578,6 +641,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (Int32, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup2_Socket_Closed ()
{
if (!Socket.OSSupportsIPv6)
@@ -623,6 +689,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup3_IPv4 ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -637,6 +706,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup3_IPv6 ()
{
if (!Socket.OSSupportsIPv6)
@@ -654,6 +726,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup3_MulticastAddr_Null ()
{
using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -670,6 +745,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, Int32)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup3_Socket_Closed ()
{
IPAddress mcast_addr = null;
@@ -712,6 +790,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_IPv4 ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -723,6 +804,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_IPv6 ()
{
if (!Socket.OSSupportsIPv6)
@@ -749,6 +833,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_LocalAddress_Null ()
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
@@ -767,6 +854,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_MulticastAddr_Null ()
{
using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
@@ -783,6 +873,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // JoinMulticastGroup (IPAddress, IPAddress)
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroup4_Socket_Closed ()
{
IPAddress mcast_addr = null;
@@ -827,6 +920,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void CloseInReceive ()
{
UdpClient client = null;
@@ -867,6 +963,9 @@ namespace MonoTests.System.Net.Sockets {
// Test for bug 324033
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void JoinMulticastGroupWithLocal ()
{
UdpClient client = new UdpClient (9001);
@@ -881,7 +980,11 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof(ArgumentNullException))]
#endif
public void BeginSendNull ()
{
UdpClient client = new UdpClient ();
@@ -904,6 +1007,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void BeginSend ()
{
UdpClient client = new UdpClient ();
@@ -958,6 +1064,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void BeginReceive ()
{
UdpClient client = new UdpClient (1237);
@@ -983,6 +1092,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Available ()
{
using (UdpClient client = new UdpClient (1238)) {
@@ -1017,6 +1129,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void EnableBroadcastDefault ()
{
UdpClient client = new UdpClient ();
@@ -1056,6 +1171,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void MulticastLoopbackDefault ()
{
UdpClient client = new UdpClient ();
@@ -1066,6 +1184,9 @@ namespace MonoTests.System.Net.Sockets {
}
[Test] // #6057
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ReceiveIPv6 ()
{
if (!Socket.OSSupportsIPv6)

View File

@@ -1,4 +1,3 @@
#if NET_4_5
using System;
using System.Net;
using System.Threading;
@@ -19,31 +18,33 @@ namespace MonoTests.System.Net.WebSockets
{
const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx";
int Port = NetworkHelpers.FindFreePort ();
HttpListener listener;
ClientWebSocket socket;
MethodInfo headerSetMethod;
[SetUp]
public void Setup ()
{
listener = new HttpListener ();
listener.Prefixes.Add ("http://localhost:" + Port + "/");
listener.Start ();
socket = new ClientWebSocket ();
HttpListener _listener;
HttpListener listener {
get {
if (_listener != null)
return _listener;
var tmp = new HttpListener ();
tmp.Prefixes.Add ("http://localhost:" + Port + "/");
tmp.Start ();
return _listener = tmp;
}
}
ClientWebSocket _socket;
ClientWebSocket socket { get { return _socket ?? (_socket = new ClientWebSocket ()); } }
MethodInfo headerSetMethod;
[TearDown]
public void Teardown ()
{
if (listener != null) {
listener.Stop ();
listener = null;
if (_listener != null) {
_listener.Stop ();
_listener = null;
}
if (socket != null) {
if (socket.State == WebSocketState.Open)
socket.CloseAsync (WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None).Wait (2000);
socket.Dispose ();
socket = null;
if (_socket != null) {
if (_socket.State == WebSocketState.Open)
_socket.CloseAsync (WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None).Wait (2000);
_socket.Dispose ();
_socket = null;
}
}
@@ -297,4 +298,3 @@ namespace MonoTests.System.Net.WebSockets
}
}
#endif

View File

@@ -71,6 +71,9 @@ namespace MonoTests.System.Net
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TestExpires ()
{
var cookies = DoRequest (A);
@@ -81,6 +84,9 @@ namespace MonoTests.System.Net
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TestInvalidCookie ()
{
var cookies = DoRequest (B);
@@ -91,6 +97,9 @@ namespace MonoTests.System.Net
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TestLocalCulture ()
{
var old = Thread.CurrentThread.CurrentCulture;
@@ -108,6 +117,9 @@ namespace MonoTests.System.Net
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TestMultiple ()
{
var cookies = DoRequest (D);
@@ -118,6 +130,9 @@ namespace MonoTests.System.Net
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TestMultiple2 ()
{
var cookies = DoRequest (E);
@@ -127,6 +142,9 @@ namespace MonoTests.System.Net
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TestQuotation ()
{
var cookies = DoRequest (F);
@@ -139,6 +157,7 @@ namespace MonoTests.System.Net
{
Socket socket;
string[] headers;
Exception ex;
public Listener (params string[] headers)
{
@@ -154,17 +173,28 @@ namespace MonoTests.System.Net
socket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
socket.Listen (1);
socket.BeginAccept ((result) => {
var accepted = socket.EndAccept (result);
HandleRequest (accepted);
try {
var accepted = socket.EndAccept (result);
HandleRequest (accepted);
} catch (Exception e) {
ex = e;
}
}, null);
}
void ThrowIfException ()
{
if (ex != null)
throw ex;
}
public void Dispose ()
{
if (socket != null) {
socket.Close ();
socket = null;
}
ThrowIfException ();
}
void HandleRequest (Socket accepted)
@@ -182,11 +212,17 @@ namespace MonoTests.System.Net
}
public EndPoint EndPoint {
get { return socket.LocalEndPoint; }
get {
ThrowIfException ();
return socket.LocalEndPoint;
}
}
public string URI {
get { return string.Format ("http://{0}/", EndPoint); }
get {
ThrowIfException ();
return string.Format ("http://{0}/", EndPoint);
}
}
}
}

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -146,6 +146,9 @@ namespace MonoTests.System.Net {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test1 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -154,10 +157,13 @@ namespace MonoTests.System.Net {
Send (ns, "GET / HTTP/1.1\r\n\r\n"); // No host
string response = Receive (ns, 512);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 400", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 400"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test2 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -166,10 +172,13 @@ namespace MonoTests.System.Net {
Send (ns, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); // no prefix
string response = Receive (ns, 512);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 400", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 400"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test3 ()
{
StringBuilder bad = new StringBuilder ();
@@ -204,11 +213,14 @@ namespace MonoTests.System.Net {
string response = Receive (ns, 512);
ns.Close ();
listener.Close ();
StringAssert.StartsWith ("HTTP/1.1 400", response, String.Format ("Failed on {0}", (int) b));
Assert.IsTrue(response.StartsWith ("HTTP/1.1 400"), String.Format ("Failed on {0}", (int) b));
}
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test4 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -217,10 +229,13 @@ namespace MonoTests.System.Net {
Send (ns, "POST /test4/ HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); // length required
string response = Receive (ns, 512);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 411", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 411"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test5 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -229,10 +244,13 @@ namespace MonoTests.System.Net {
Send (ns, "POST / HTTP/1.1\r\nHost: 127.0.0.1\r\nTransfer-Encoding: pepe\r\n\r\n"); // not implemented
string response = Receive (ns, 512);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 501", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 501"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test6 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -242,10 +260,13 @@ namespace MonoTests.System.Net {
Send (ns, "POST /test6/ HTTP/1.1\r\nHost: 127.0.0.1\r\nTransfer-Encoding: identity\r\n\r\n");
string response = Receive (ns, 512);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 501", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 501"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test7 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -257,11 +278,14 @@ namespace MonoTests.System.Net {
ctx.Response.Close ();
string response = Receive (ns, 1024);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 200", response);
StringAssert.Contains ("Transfer-Encoding: chunked", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 200"));
Assert.IsTrue(response.Contains ("Transfer-Encoding: chunked"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test8 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -274,11 +298,14 @@ namespace MonoTests.System.Net {
ctx.Response.Close ();
string response = Receive (ns, 512);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 200", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 200"));
Assert.IsTrue (-1 == response.IndexOf ("Transfer-Encoding: chunked"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test9 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -290,10 +317,13 @@ namespace MonoTests.System.Net {
string response = ReceiveWithTimeout (ns, 512, 1000, out timeout);
ns.Close ();
Assert.IsFalse (timeout);
StringAssert.StartsWith ("HTTP/1.1 411", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 411"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test10 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -306,10 +336,13 @@ namespace MonoTests.System.Net {
string response = ReceiveWithTimeout (ns, 512, 1000, out timeout);
ns.Close ();
Assert.IsFalse (timeout);
StringAssert.StartsWith ("HTTP/1.1 411", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 411"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test11 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -320,10 +353,13 @@ namespace MonoTests.System.Net {
ns.GetSocket ().Shutdown (SocketShutdown.Send);
string input = Receive (ns, 512);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 400", input);
Assert.IsTrue(input.StartsWith ("HTTP/1.1 400"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test12 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -334,10 +370,13 @@ namespace MonoTests.System.Net {
ns.GetSocket ().Shutdown (SocketShutdown.Send);
string input = Receive (ns, 512);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 400", input);
Assert.IsTrue(input.StartsWith ("HTTP/1.1 400"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test13 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -348,13 +387,16 @@ namespace MonoTests.System.Net {
ns.GetSocket ().Shutdown (SocketShutdown.Send);
string input = Receive (ns, 512);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 400", input);
Assert.IsTrue(input.StartsWith ("HTTP/1.1 400"));
}
HttpListenerRequest test14_request;
ManualResetEvent test_evt;
bool test14_error;
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test14 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -391,6 +433,9 @@ namespace MonoTests.System.Net {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test15 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -413,6 +458,9 @@ namespace MonoTests.System.Net {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test16 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -437,6 +485,9 @@ namespace MonoTests.System.Net {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test17 ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -448,11 +499,14 @@ namespace MonoTests.System.Net {
ctx.Response.Close ();
string response = Receive (ns, 1024);
ns.Close ();
StringAssert.StartsWith ("HTTP/1.1 200", response);
StringAssert.Contains ("Transfer-Encoding: chunked", response);
Assert.IsTrue(response.StartsWith ("HTTP/1.1 200"));
Assert.IsTrue(response.Contains ("Transfer-Encoding: chunked"));
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test_MultipleClosesOnOuputStreamAllowed ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -483,6 +537,9 @@ namespace MonoTests.System.Net {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ReceiveCookiesFromClient ()
{
sendCookiePort = NetworkHelpers.FindFreePort ();
@@ -529,6 +586,9 @@ namespace MonoTests.System.Net {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void SendCookiestoClient ()
{
receiveCookiePort = NetworkHelpers.FindFreePort ();
@@ -580,6 +640,9 @@ namespace MonoTests.System.Net {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void MultiResponses ()
{
echoServerPort = NetworkHelpers.FindFreePort ();
@@ -647,6 +710,9 @@ namespace MonoTests.System.Net {
[TestFixture]
public class HttpListenerBugs {
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void TestNonChunkedAsync ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -701,6 +767,9 @@ namespace MonoTests.System.Net {
// a documented pattern to close the connection
//
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test_MultipleConnections ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -731,6 +800,9 @@ namespace MonoTests.System.Net {
// Test case for bug 341443, an pretty old bug, filed on November of 2007.
//
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test_HostInUri ()
{
var wait = new ManualResetEvent (false);
@@ -760,6 +832,9 @@ namespace MonoTests.System.Net {
}
[Test] // bug #513849
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void ClosePort ()
{
var port = NetworkHelpers.FindFreePort ();
@@ -783,6 +858,9 @@ namespace MonoTests.System.Net {
// does not also listen to another interface.
//
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void BindToSingleInterface ()
{
IPAddress [] machineAddress = null;
@@ -809,6 +887,9 @@ namespace MonoTests.System.Net {
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void BindToAllInterfaces ()
{
var h = new HttpListener ();
@@ -821,6 +902,9 @@ namespace MonoTests.System.Net {
// Test case for bug #31209
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void Test_EmptyLineAtStart ()
{
var port = NetworkHelpers.FindFreePort ();

Some files were not shown because too many files have changed in this diff Show More