You've already forked linux-packaging-mono
Imported Upstream version 3.12.0
Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
This commit is contained in:
@ -30,14 +30,13 @@ namespace MonoCasTests.System.Net {
|
||||
static ManualResetEvent reset;
|
||||
private string message;
|
||||
private string hostname;
|
||||
private IPAddress ip;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void FixtureSetUp ()
|
||||
{
|
||||
reset = new ManualResetEvent (false);
|
||||
hostname = Dns.GetHostName ();
|
||||
ip = Dns.Resolve (site).AddressList[0];
|
||||
var ip = Dns.Resolve (site).AddressList[0];
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
|
@ -36,6 +36,14 @@ using NUnit.Framework;
|
||||
namespace MonoTests.System.Net {
|
||||
[TestFixture]
|
||||
public class HttpListenerTest {
|
||||
|
||||
int port;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp () {
|
||||
port = new Random ().Next (7777, 8000);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DefaultProperties ()
|
||||
{
|
||||
@ -115,7 +123,7 @@ namespace MonoTests.System.Net {
|
||||
socket.Listen(1);
|
||||
}
|
||||
}
|
||||
catch(Exception ex) {
|
||||
catch(Exception) {
|
||||
//Can be AccessDeniedException(ports 80/443 need root access) or
|
||||
//SocketException because other application is listening
|
||||
return false;
|
||||
@ -152,10 +160,12 @@ namespace MonoTests.System.Net {
|
||||
[Test]
|
||||
public void TwoListeners_SameAddress ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
Assert.Ignore ("port");
|
||||
HttpListener listener1 = new HttpListener ();
|
||||
listener1.Prefixes.Add ("http://127.0.0.1:7777/");
|
||||
listener1.Prefixes.Add ("http://127.0.0.1:" + port + "/");
|
||||
HttpListener listener2 = new HttpListener ();
|
||||
listener2.Prefixes.Add ("http://127.0.0.1:7777/hola/");
|
||||
listener2.Prefixes.Add ("http://127.0.0.1:" + port + "/hola/");
|
||||
listener1.Start ();
|
||||
listener2.Start ();
|
||||
}
|
||||
@ -164,10 +174,12 @@ namespace MonoTests.System.Net {
|
||||
[ExpectedException (typeof (HttpListenerException))]
|
||||
public void TwoListeners_SameURL ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
Assert.Ignore ("port");
|
||||
HttpListener listener1 = new HttpListener ();
|
||||
listener1.Prefixes.Add ("http://127.0.0.1:7777/hola/");
|
||||
listener1.Prefixes.Add ("http://127.0.0.1:" + port + "/hola/");
|
||||
HttpListener listener2 = new HttpListener ();
|
||||
listener2.Prefixes.Add ("http://127.0.0.1:7777/hola/");
|
||||
listener2.Prefixes.Add ("http://127.0.0.1:" + port + "/hola/");
|
||||
listener1.Start ();
|
||||
listener2.Start ();
|
||||
}
|
||||
@ -176,8 +188,10 @@ namespace MonoTests.System.Net {
|
||||
[ExpectedException (typeof (HttpListenerException))]
|
||||
public void MultipleSlashes ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
Assert.Ignore ("port");
|
||||
HttpListener listener = new HttpListener ();
|
||||
listener.Prefixes.Add ("http://localhost:7777/hola////");
|
||||
listener.Prefixes.Add ("http://localhost:" + port + "/hola////");
|
||||
// this one throws on Start(), not when adding it.
|
||||
listener.Start ();
|
||||
}
|
||||
@ -186,8 +200,10 @@ namespace MonoTests.System.Net {
|
||||
[ExpectedException (typeof (HttpListenerException))]
|
||||
public void PercentSign ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
Assert.Ignore ("port");
|
||||
HttpListener listener = new HttpListener ();
|
||||
listener.Prefixes.Add ("http://localhost:7777/hola%3E/");
|
||||
listener.Prefixes.Add ("http://localhost:" + port + "/hola%3E/");
|
||||
// this one throws on Start(), not when adding it.
|
||||
listener.Start ();
|
||||
}
|
||||
@ -202,8 +218,10 @@ namespace MonoTests.System.Net {
|
||||
[Test]
|
||||
public void CloseTwice ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
Assert.Ignore ("port");
|
||||
HttpListener listener = new HttpListener ();
|
||||
listener.Prefixes.Add ("http://localhost:7777/hola/");
|
||||
listener.Prefixes.Add ("http://localhost:" + port + "/hola/");
|
||||
listener.Start ();
|
||||
listener.Close ();
|
||||
listener.Close ();
|
||||
@ -212,8 +230,10 @@ namespace MonoTests.System.Net {
|
||||
[Test]
|
||||
public void StartStopStart ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
Assert.Ignore ("port");
|
||||
HttpListener listener = new HttpListener ();
|
||||
listener.Prefixes.Add ("http://localhost:7777/hola/");
|
||||
listener.Prefixes.Add ("http://localhost:" + port + "/hola/");
|
||||
listener.Start ();
|
||||
listener.Stop ();
|
||||
listener.Start ();
|
||||
@ -223,8 +243,10 @@ namespace MonoTests.System.Net {
|
||||
[Test]
|
||||
public void StartStopDispose ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
Assert.Ignore ("port");
|
||||
using (HttpListener listener = new HttpListener ()){
|
||||
listener.Prefixes.Add ("http://localhost:7777/hola/");
|
||||
listener.Prefixes.Add ("http://localhost:" + port + "/hola/");
|
||||
listener.Start ();
|
||||
listener.Stop ();
|
||||
}
|
||||
@ -240,8 +262,10 @@ namespace MonoTests.System.Net {
|
||||
[Test]
|
||||
public void AbortTwice ()
|
||||
{
|
||||
if (!CanOpenPort (port))
|
||||
Assert.Ignore ("port");
|
||||
HttpListener listener = new HttpListener ();
|
||||
listener.Prefixes.Add ("http://localhost:7777/hola/");
|
||||
listener.Prefixes.Add ("http://localhost:" + port + "/hola/");
|
||||
listener.Start ();
|
||||
listener.Abort ();
|
||||
listener.Abort ();
|
||||
|
@ -31,7 +31,7 @@ using System.Net;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MoonTest.System.Net {
|
||||
namespace MonoTests.System.Net {
|
||||
|
||||
[TestFixture]
|
||||
public class NetworkCredentialTest {
|
||||
|
@ -2221,6 +2221,28 @@ namespace MonoTests.System.Net
|
||||
webClient.UploadFileAsync (uri, "PUT", tempFile);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UploadFileAsyncContentType ()
|
||||
{
|
||||
var serverUri = "http://localhost:13370/";
|
||||
var filename = Path.GetTempFileName ();
|
||||
|
||||
HttpListener listener = new HttpListener ();
|
||||
listener.Prefixes.Add (serverUri);
|
||||
listener.Start ();
|
||||
|
||||
using (var client = new WebClient ())
|
||||
{
|
||||
client.UploadFileTaskAsync (new Uri (serverUri), filename);
|
||||
var request = listener.GetContext ().Request;
|
||||
|
||||
var expected = "multipart/form-data; boundary=------------";
|
||||
Assert.AreEqual (expected.Length + 15, request.ContentType.Length);
|
||||
Assert.AreEqual (expected, request.ContentType.Substring (0, expected.Length));
|
||||
}
|
||||
listener.Close ();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NET_4_0
|
||||
|
Reference in New Issue
Block a user