[System*] Throw a PlatformNotSupported exception when using the networking stack...
[mono.git] / mcs / class / System.Net.Http / Test / System.Net.Http / HttpClientTest.cs
index f1af864e214943a61321e2cf20cf93ff4a215cc7..d9aab417dfa00762ff0848ae78385316ada5a7e3 100644 (file)
@@ -263,6 +263,10 @@ namespace MonoTests.System.Net.Http
 
 
                [Test]
+#if FEATURE_NO_BSD_SOCKETS
+               // Using HttpClientHandler, which indirectly requires BSD sockets.
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void CancelRequestViaProxy ()
                {
                        var handler = new HttpClientHandler {
@@ -321,7 +325,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Proxy_Disabled ()
                {
                        var pp = WebRequest.DefaultWebProxy;
@@ -398,7 +404,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_Default ()
                {
                        bool? failed = null;
@@ -443,7 +451,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_Version_1_0 ()
                {
                        bool? failed = null;
@@ -491,7 +501,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_ClientHandlerSettings ()
                {
                        bool? failed = null;
@@ -556,7 +568,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_CustomHeaders ()
                {
                        bool? failed = null;
@@ -621,7 +635,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_CustomHeaders_SpecialSeparators ()
                {
                        bool? failed = null;
@@ -656,7 +672,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_CustomHeaders_Host ()
                {
                        bool? failed = null;
@@ -690,7 +708,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Transfer_Encoding_Chunked ()
                {
                        bool? failed = null;
@@ -720,7 +740,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Transfer_Encoding_Custom ()
                {
                        bool? failed = null;
@@ -749,7 +771,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_Content ()
                {
                        var listener = CreateListener (l => {
@@ -777,7 +801,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_Content_MaxResponseContentBufferSize ()
                {
                        var listener = CreateListener (l => {
@@ -800,7 +826,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_Content_MaxResponseContentBufferSize_Error ()
                {
                        var listener = CreateListener (l => {
@@ -827,7 +855,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_NoContent ()
                {
                        foreach (var method in new HttpMethod[] { HttpMethod.Post, HttpMethod.Put, HttpMethod.Delete }) {
@@ -860,7 +890,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Complete_Error ()
                {
                        var listener = CreateListener (l => {
@@ -881,7 +913,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Content_Get ()
                {
                        var listener = CreateListener (l => {
@@ -901,7 +935,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Content_BomEncoding ()
                {
                        var listener = CreateListener (l => {
@@ -926,7 +962,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Content_Put ()
                {
                        bool passed = false;
@@ -952,7 +990,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void Send_Content_Put_CustomStream ()
                {
                        bool passed = false;
@@ -1055,7 +1095,9 @@ namespace MonoTests.System.Net.Http
 
                [Test]
                [Category ("MobileNotWorking")] // Missing encoding
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void GetString_Many ()
                {
                        Action<HttpListenerContext> context = (HttpListenerContext l) => {
@@ -1085,7 +1127,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void GetByteArray_ServerError ()
                {
                        var listener = CreateListener (l => {
@@ -1108,7 +1152,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void DisallowAutoRedirect ()
                {
                        var listener = CreateListener (l => {
@@ -1137,7 +1183,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                public void RequestUriAfterRedirect ()
                {
                        var listener = CreateListener (l => {
@@ -1178,7 +1226,9 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
-               [Category ("RequiresBSDSockets")]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                /*
                 * Properties may only be modified before sending the first request.
                 */
@@ -1209,6 +1259,10 @@ namespace MonoTests.System.Net.Http
                }
 
                [Test]
+#if FEATURE_NO_BSD_SOCKETS
+               // Using HttpClientHandler, which indirectly requires BSD sockets.
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
                /*
                 * However, this policy is not enforced for custom handlers and there
                 * is also no way a derived class could tell its HttpClientHandler parent