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=b099f07d75ebc9f2aece60592551b7ae33d8e77f;hpb=f1f8b8a867c800b21b6a03767252403c2f72cae2;p=mono.git diff --git a/mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs b/mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs index b099f07d75e..20763df5802 100644 --- a/mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs +++ b/mcs/class/System/Test/System.Net/HttpListenerPrefixCollectionTest.cs @@ -26,17 +26,21 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_2_0 using System; 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 (); @@ -47,6 +51,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void DefaultProperties () { HttpListener listener = new HttpListener (); @@ -58,12 +65,16 @@ namespace MonoTests.System.Net { } [Test] +#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,12 +82,16 @@ namespace MonoTests.System.Net { } [Test] +#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"); @@ -85,6 +100,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void EndsWithSlash () { HttpListener listener = new HttpListener (); @@ -92,6 +110,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void DifferentPath () { HttpListener listener = new HttpListener (); @@ -101,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 (); @@ -109,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 (); @@ -117,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 (); @@ -125,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 (); @@ -134,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 (); @@ -142,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. @@ -155,6 +196,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void PercentSign () { HttpListener listener = new HttpListener (); @@ -168,6 +212,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void Disposed1 () { HttpListener listener = new HttpListener (); @@ -179,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 (); @@ -189,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 (); @@ -199,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 (); @@ -209,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 (); @@ -220,6 +283,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void Disposed6 () { HttpListener listener = new HttpListener (); @@ -233,6 +299,9 @@ namespace MonoTests.System.Net { } [Test] +#if FEATURE_NO_BSD_SOCKETS + [ExpectedException (typeof (PlatformNotSupportedException))] +#endif public void Disposed7 () { HttpListener listener = new HttpListener (); @@ -248,5 +317,4 @@ namespace MonoTests.System.Net { } } } -#endif