[socket] Add EPROTOTYPE error case (#4391)
[mono.git] / mcs / class / System / Test / System.Net.Sockets / SocketTest.cs
index 14ec2700869c289ee1159851c5402e07138b70a5..bce47bcbf0dfc43890e39c8e81e064005e49a0ec 100755 (executable)
@@ -3720,8 +3720,11 @@ namespace MonoTests.System.Net.Sockets
 
                [Test]
                [Category ("NotOnMac")]
-                public void ConnectedProperty ()
-                {
+#if FULL_AOT_DESKTOP
+               [Ignore ("https://bugzilla.xamarin.com/show_bug.cgi?id=52157")]
+#endif
+               public void ConnectedProperty ()
+               {
                        TcpListener listener = new TcpListener (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
                        listener.Start();
 
@@ -4672,6 +4675,29 @@ namespace MonoTests.System.Net.Sockets
 
                        Assert.IsTrue (mre.WaitOne (1000), "ConnectedAsync timeout");
                }
+
+               [Test] // Covers https://bugzilla.xamarin.com/show_bug.cgi?id=52549
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+               public void SocketMismatchProtocol ()
+               {
+                       try {
+                               using (Socket socket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Tcp));
+                               Assert.Fail ("#1");
+                       } catch (SocketException e) {
+                               // Only work on OSX
+                               // Assert.AreEqual(SocketError.ProtocolType, e.SocketErrorCode, "#2");
+                       }
+
+                       try {
+                               using (Socket socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Udp));
+                               Assert.Fail ("#3");
+                       } catch (SocketException e) {
+                               // Only work on OSX
+                               // Assert.AreEqual(SocketError.ProtocolType, e.SocketErrorCode, "#4");
+                       }
+               }
        }
 }