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 ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void DefaultProperties ()
{
HttpListener listener = new HttpListener ();
}
[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");
}
[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");
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void EndsWithSlash ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void DifferentPath ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void NL_Clear ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void NL_Remove ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void NL_RemoveBadUri ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#else
[ExpectedException (typeof (ArgumentException))]
+#endif
public void NL_AddBadUri ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#else
[ExpectedException (typeof (ArgumentException))]
+#endif
public void NoHostInUrl ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void MultipleSlashes ()
{
// this one throws on Start(), not when adding it.
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void PercentSign ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void Disposed1 ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#else
[ExpectedException (typeof (ObjectDisposedException))]
+#endif
public void Disposed2 ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#else
[ExpectedException (typeof (ObjectDisposedException))]
+#endif
public void Disposed3 ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#else
[ExpectedException (typeof (ObjectDisposedException))]
+#endif
public void Disposed4 ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#else
[ExpectedException (typeof (ObjectDisposedException))]
+#endif
public void Disposed5 ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void Disposed6 ()
{
HttpListener listener = new HttpListener ();
}
[Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
public void Disposed7 ()
{
HttpListener listener = new HttpListener ();