X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FTest%2FSystem.Net%2FHttpListenerPrefixCollectionTest.cs;h=20763df580258234f11c7b5f04b0c6262fcf4626;hb=bc83d048ba196d3671aa2306c1f3f495936bc08b;hp=21589dc6c30914ebe227c22b04a99143a720457e;hpb=0a042da3ef8da945d51f0e9405ff2fcb57d39773;p=mono.git diff --git a/mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs b/mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs index 21589dc6c30..20763df5802 100644 --- a/mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs +++ b/mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs @@ -31,11 +31,16 @@ using System.Net; using NUnit.Framework; using HLPC=System.Net.HttpListenerPrefixCollection; +using MonoTests.Helpers; + namespace MonoTests.System.Net { [TestFixture] public class HttpListenerPrefixCollectionTest { // NL -> Not listening -> tests when listener.IsListening == false [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void NL_DefaultProperties () { HttpListener listener = new HttpListener (); @@ -46,6 +51,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void DefaultProperties () { HttpListener listener = new HttpListener (); @@ -57,13 +65,16 @@ namespace MonoTests.System.Net { } [Test] - [Category ("RequiresBSDSockets")] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void AddOne () { + var port = NetworkHelpers.FindFreePort (); HttpListener listener = new HttpListener (); HLPC coll = listener.Prefixes; listener.Start (); - coll.Add ("http://127.0.0.1:8181/"); + coll.Add ($"http://127.0.0.1:{port}/"); Assert.AreEqual (1, coll.Count, "Count"); Assert.IsFalse (coll.IsReadOnly, "IsReadOnly"); Assert.IsFalse (coll.IsSynchronized, "IsSynchronized"); @@ -71,13 +82,16 @@ namespace MonoTests.System.Net { } [Test] - [Category ("RequiresBSDSockets")] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void Duplicate () { + var port = NetworkHelpers.FindFreePort (); HttpListener listener = new HttpListener (); HLPC coll = listener.Prefixes; - coll.Add ("http://127.0.0.1:8181/"); - coll.Add ("http://127.0.0.1:8181/"); + coll.Add ($"http://127.0.0.1:{port}/"); + coll.Add ($"http://127.0.0.1:{port}/"); listener.Start (); Assert.AreEqual (1, coll.Count, "Count"); Assert.IsFalse (coll.IsReadOnly, "IsReadOnly"); @@ -86,6 +100,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void EndsWithSlash () { HttpListener listener = new HttpListener (); @@ -93,6 +110,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void DifferentPath () { HttpListener listener = new HttpListener (); @@ -102,6 +122,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void NL_Clear () { HttpListener listener = new HttpListener (); @@ -110,6 +133,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void NL_Remove () { HttpListener listener = new HttpListener (); @@ -118,6 +144,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void NL_RemoveBadUri () { HttpListener listener = new HttpListener (); @@ -126,7 +155,11 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#else [ExpectedException (typeof (ArgumentException))] +#endif public void NL_AddBadUri () { HttpListener listener = new HttpListener (); @@ -135,7 +168,11 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#else [ExpectedException (typeof (ArgumentException))] +#endif public void NoHostInUrl () { HttpListener listener = new HttpListener (); @@ -143,6 +180,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void MultipleSlashes () { // this one throws on Start(), not when adding it. @@ -156,6 +196,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void PercentSign () { HttpListener listener = new HttpListener (); @@ -169,6 +212,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void Disposed1 () { HttpListener listener = new HttpListener (); @@ -180,7 +226,11 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#else [ExpectedException (typeof (ObjectDisposedException))] +#endif public void Disposed2 () { HttpListener listener = new HttpListener (); @@ -190,7 +240,11 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#else [ExpectedException (typeof (ObjectDisposedException))] +#endif public void Disposed3 () { HttpListener listener = new HttpListener (); @@ -200,7 +254,11 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#else [ExpectedException (typeof (ObjectDisposedException))] +#endif public void Disposed4 () { HttpListener listener = new HttpListener (); @@ -210,7 +268,11 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#else [ExpectedException (typeof (ObjectDisposedException))] +#endif public void Disposed5 () { HttpListener listener = new HttpListener (); @@ -221,6 +283,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void Disposed6 () { HttpListener listener = new HttpListener (); @@ -234,6 +299,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void Disposed7 () { HttpListener listener = new HttpListener ();