[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / System / Test / System.Net.Sockets / UdpClientTest.cs
index 51c3ac795b52decb800db45596cb972571e9f4d2..6dd0b0c1531bf1e1d764e27c071b09d699b6c0f9 100644 (file)
@@ -26,21 +26,17 @@ namespace MonoTests.System.Net.Sockets {
                        Assert.IsNotNull (s, "Client");
                        Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "Client:AddressFamily");
                        Assert.IsFalse (s.Connected, "Client:Connected");
-#if NET_2_0
                        Assert.IsFalse (s.IsBound, "#A:Client:IsBound");
-#endif
                        Assert.IsNull (s.LocalEndPoint, "Client:LocalEndPoint");
                        Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "Client:ProtocolType");
                        Assert.IsNull (s.RemoteEndPoint, "Client:RemoteEndPoint");
                        Assert.AreEqual (SocketType.Dgram, s.SocketType, "Client:SocketType");
                        Assert.IsFalse (client.Active, "Active");
-#if NET_2_0
                        Assert.IsFalse (client.DontFragment, "DontFragment");
                        Assert.IsFalse (client.EnableBroadcast, "EnableBroadcast");
                        //Assert.IsFalse (client.ExclusiveAddressUse, "ExclusiveAddressUse");
                        Assert.IsTrue (client.MulticastLoopback, "MulticastLoopback");
                        //Assert.AreEqual (32, client.Ttl, "Ttl");
-#endif
                        client.Close ();
                }
 
@@ -55,27 +51,19 @@ namespace MonoTests.System.Net.Sockets {
                        Assert.IsNotNull (s, "#A:Client");
                        Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "#A:Client:AddressFamily");
                        Assert.IsFalse (s.Connected, "#A:Client:Connected");
-#if NET_2_0
                        Assert.IsFalse (s.IsBound, "#A:Client:IsBound");
-#endif
                        Assert.IsNull (s.LocalEndPoint, "#A:Client:LocalEndPoint");
                        Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "#A:Client:ProtocolType");
                        Assert.IsNull (s.RemoteEndPoint, "#A:Client:RemoteEndPoint");
                        Assert.AreEqual (SocketType.Dgram, s.SocketType, "#A:Client:SocketType");
                        Assert.IsFalse (client.Active, "#A:Active");
-#if NET_2_0
                        //Assert.IsFalse (client.DontFragment, "#A:DontFragment");
                        Assert.IsFalse (client.EnableBroadcast, "#A:EnableBroadcast");
                        //Assert.IsFalse (client.ExclusiveAddressUse, "#A:ExclusiveAddressUse");
                        Assert.IsTrue (client.MulticastLoopback, "#A:MulticastLoopback");
                        //Assert.AreEqual (32, client.Ttl, "#A:Ttl");
-#endif
 
-#if NET_2_0
                        if (!Socket.OSSupportsIPv6)
-#else
-                       if (!Socket.SupportsIPv6)
-#endif
                                Assert.Ignore ("IPv6 not enabled.");
 
                        client = new MyUdpClient (AddressFamily.InterNetworkV6);
@@ -83,21 +71,17 @@ namespace MonoTests.System.Net.Sockets {
                        Assert.IsNotNull (s, "#B:Client");
                        Assert.AreEqual (AddressFamily.InterNetworkV6, s.AddressFamily, "#B:Client:AddressFamily");
                        Assert.IsFalse (s.Connected, "#B:Client:Connected");
-#if NET_2_0
                        Assert.IsFalse (s.IsBound, "#A:Client:IsBound");
-#endif
                        Assert.IsNull (s.LocalEndPoint, "#B:Client:LocalEndPoint");
                        Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "#B:Client:ProtocolType");
                        Assert.IsNull (s.RemoteEndPoint, "#B:Client:RemoteEndPoint");
                        Assert.AreEqual (SocketType.Dgram, s.SocketType, "#B:Client:SocketType");
                        Assert.IsFalse (client.Active, "#B:Active");
-#if NET_2_0
                        //Assert.IsFalse (client.DontFragment, "#B:DontFragment");
                        Assert.IsFalse (client.EnableBroadcast, "#B:EnableBroadcast");
                        //Assert.IsFalse (client.ExclusiveAddressUse, "#B:ExclusiveAddressUse");
                        Assert.IsTrue (client.MulticastLoopback, "#B:MulticastLoopback");
                        //Assert.AreEqual (32, client.Ttl, "#B:Ttl");
-#endif
                        client.Close ();
                }
 
@@ -110,15 +94,10 @@ namespace MonoTests.System.Net.Sockets {
                        } catch (ArgumentException ex) {
                                Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
                                Assert.IsNull (ex.InnerException, "#A3");
-#if NET_2_0
                                // 'UDP' Client can only accept InterNetwork or InterNetworkV6
                                // addresses
                                Assert.IsNotNull (ex.Message, "#A4");
                                Assert.AreEqual ("family", ex.ParamName, "#A5");
-#else
-                               Assert.AreEqual ("family", ex.Message, "#A4");
-                               Assert.IsNull (ex.ParamName, "#A5");
-#endif
                        }
 
                        try {
@@ -127,13 +106,8 @@ namespace MonoTests.System.Net.Sockets {
                        } catch (ArgumentException ex) {
                                Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
                                Assert.IsNull (ex.InnerException, "#B3");
-#if NET_2_0
                                Assert.IsNotNull (ex.Message, "#B4");
                                Assert.AreEqual ("family", ex.ParamName, "#B5");
-#else
-                               Assert.AreEqual ("family", ex.Message, "#B4");
-                               Assert.IsNull (ex.ParamName, "#B5");
-#endif
                        }
                }
 
@@ -149,19 +123,15 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNotNull (s, "#A:Client");
                                Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "#A:Client:AddressFamily");
                                Assert.IsFalse (s.Connected, "#A:Client:Connected");
-       #if NET_2_0
                                Assert.IsTrue (s.IsBound, "#A:Client:IsBound");
-       #endif
                                Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "#A:Client:ProtocolType");
                                Assert.AreEqual (SocketType.Dgram, s.SocketType, "#A:Client:SocketType");
                                Assert.IsFalse (client.Active, "#A:Active");
-       #if NET_2_0
                                Assert.IsFalse (client.DontFragment, "#A:DontFragment");
                                Assert.IsFalse (client.EnableBroadcast, "#A:EnableBroadcast");
                                //Assert.IsFalse (client.ExclusiveAddressUse, "#A:ExclusiveAddressUse");
                                Assert.IsTrue (client.MulticastLoopback, "#A:MulticastLoopback");
                                //Assert.AreEqual (32, client.Ttl, "#A:Ttl");
-       #endif
                                localEP = s.LocalEndPoint as IPEndPoint;
                                Assert.IsNotNull (localEP, "#A:Client:LocalEndpoint");
                                Assert.AreEqual (IPAddress.Any, localEP.Address, "#A:Client:LocalEndPoint/Address");
@@ -173,19 +143,15 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNotNull (s, "#B:Client");
                                Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "#B:Client:AddressFamily");
                                Assert.IsFalse (s.Connected, "#B:Client:Connected");
-       #if NET_2_0
                                Assert.IsTrue (s.IsBound, "#B:Client:IsBound");
-       #endif
                                Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "#B:Client:ProtocolType");
                                Assert.AreEqual (SocketType.Dgram, s.SocketType, "#B:Client:SocketType");
                                Assert.IsFalse (client.Active, "#B:Active");
-       #if NET_2_0
                                Assert.IsFalse (client.DontFragment, "#B:DontFragment");
                                Assert.IsFalse (client.EnableBroadcast, "#B:EnableBroadcast");
                                //Assert.IsFalse (client.ExclusiveAddressUse, "#B:ExclusiveAddressUse");
                                Assert.IsTrue (client.MulticastLoopback, "#B:MulticastLoopback");
                                //Assert.AreEqual (32, client.Ttl, "#B:Ttl");
-       #endif
                                localEP = s.LocalEndPoint as IPEndPoint;
                                Assert.IsNotNull (localEP, "#B:Client:LocalEndpoint");
                                Assert.AreEqual (IPAddress.Any, localEP.Address, "#B:Client:LocalEndPoint/Address");
@@ -234,19 +200,15 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNotNull (s, "#A:Client");
                                Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "#A:Client:AddressFamily");
                                Assert.IsFalse (s.Connected, "#A:Client:Connected");
-#if NET_2_0
                                Assert.IsTrue (s.IsBound, "#A:Client:IsBound");
-#endif
                                Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "#A:Client:ProtocolType");
                                Assert.AreEqual (SocketType.Dgram, s.SocketType, "#A:Client:SocketType");
                                Assert.IsFalse (client.Active, "#A:Active");
-#if NET_2_0
                                Assert.IsFalse (client.DontFragment, "#A:DontFragment");
                                Assert.IsFalse (client.EnableBroadcast, "#A:EnableBroadcast");
                                //Assert.IsFalse (client.ExclusiveAddressUse, "#A:ExclusiveAddressUse");
                                Assert.IsTrue (client.MulticastLoopback, "#A:MulticastLoopback");
                                //Assert.AreEqual (32, client.Ttl, "#A:Ttl");
-#endif
                                localEP = s.LocalEndPoint as IPEndPoint;
                                Assert.IsNotNull (localEP, "#A:Client:LocalEndpoint");
                                Assert.IsFalse (object.ReferenceEquals (clientEP, localEP), "#A:Client:LocalEndPoint/ReferenceEquality");
@@ -282,30 +244,22 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNotNull (s, "#A:Client");
                                Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "#A:Client:AddressFamily");
                                Assert.IsFalse (s.Connected, "#A:Client:Connected");
-#if NET_2_0
                                Assert.IsTrue (s.IsBound, "#A:Client:IsBound");
-#endif
                                Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "#A:Client:ProtocolType");
                                Assert.AreEqual (SocketType.Dgram, s.SocketType, "#A:Client:SocketType");
                                Assert.IsFalse (client.Active, "#A:Active");
-#if NET_2_0
                                //Assert.IsFalse (client.DontFragment, "#A:DontFragment");
                                Assert.IsFalse (client.EnableBroadcast, "#A:EnableBroadcast");
                                //Assert.IsFalse (client.ExclusiveAddressUse, "#A:ExclusiveAddressUse");
                                Assert.IsTrue (client.MulticastLoopback, "#A:MulticastLoopback");
                                //Assert.AreEqual (32, client.Ttl, "#A:Ttl");
-#endif
                                localEP = s.LocalEndPoint as IPEndPoint;
                                Assert.IsNotNull (localEP, "#A:Client:LocalEndpoint");
                                Assert.AreEqual (IPAddress.Any, localEP.Address, "#A:Client:LocalEndPoint/Address");
                                Assert.AreEqual (AddressFamily.InterNetwork, localEP.AddressFamily, "#A:Client:LocalEndPoint/AddressFamily");
                        }
 
-#if NET_2_0
                        if (!Socket.OSSupportsIPv6)
-#else
-                       if (!Socket.SupportsIPv6)
-#endif
                                Assert.Ignore ("IPv6 not enabled.");
 
                        using (MyUdpClient client = new MyUdpClient (IPEndPoint.MaxPort, AddressFamily.InterNetworkV6))
@@ -314,19 +268,15 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNotNull (s, "#B:Client");
                                Assert.AreEqual (AddressFamily.InterNetworkV6, s.AddressFamily, "#B:Client:AddressFamily");
                                Assert.IsFalse (s.Connected, "#B:Client:Connected");
-#if NET_2_0
                                Assert.IsTrue (s.IsBound, "#B:Client:IsBound");
-#endif
                                Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "#B:Client:ProtocolType");
                                Assert.AreEqual (SocketType.Dgram, s.SocketType, "#B:Client:SocketType");
                                Assert.IsFalse (client.Active, "#B:Active");
-#if NET_2_0
                                //Assert.IsFalse (client.DontFragment, "#B:DontFragment");
                                Assert.IsFalse (client.EnableBroadcast, "#B:EnableBroadcast");
                                //Assert.IsFalse (client.ExclusiveAddressUse, "#B:ExclusiveAddressUse");
                                Assert.IsTrue (client.MulticastLoopback, "#B:MulticastLoopback");
                                //Assert.AreEqual (32, client.Ttl, "#B:Ttl");
-#endif
                                localEP = s.LocalEndPoint as IPEndPoint;
                                Assert.IsNotNull (localEP, "#B:Client:LocalEndpoint");
                                Assert.AreEqual (IPAddress.IPv6Any, localEP.Address, "#B:Client:LocalEndPoint/Address");
@@ -345,15 +295,10 @@ namespace MonoTests.System.Net.Sockets {
                                // family
                                Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
                                Assert.IsNull (ex.InnerException, "#A3");
-#if NET_2_0
                                // 'UDP' Client can only accept InterNetwork or InterNetworkV6
                                // addresses
                                Assert.IsNotNull (ex.Message, "#A4");
                                Assert.AreEqual ("family", ex.ParamName, "#A5");
-#else
-                               Assert.AreEqual ("family", ex.Message, "#A4");
-                               Assert.IsNull (ex.ParamName, "#A5");
-#endif
                        }
 
                        try {
@@ -363,15 +308,10 @@ namespace MonoTests.System.Net.Sockets {
                                // family
                                Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
                                Assert.IsNull (ex.InnerException, "#B3");
-#if NET_2_0
                                // 'UDP' Client can only accept InterNetwork or InterNetworkV6
                                // addresses
                                Assert.IsNotNull (ex.Message, "#B4");
                                Assert.AreEqual ("family", ex.ParamName, "#B5");
-#else
-                               Assert.AreEqual ("family", ex.Message, "#B4");
-                               Assert.IsNull (ex.ParamName, "#B5");
-#endif
                        }
                }
 
@@ -415,19 +355,15 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNotNull (s, "#A:Client");
                                Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "#A:Client:AddressFamily");
                                Assert.IsTrue (s.Connected, "#A:Client:Connected");
-#if NET_2_0
                                Assert.IsTrue (s.IsBound, "#A:Client:IsBound");
-#endif
                                Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "#A:Client:ProtocolType");
                                Assert.AreEqual (SocketType.Dgram, s.SocketType, "#A:Client:SocketType");
                                Assert.IsTrue (client.Active, "#A:Active");
-#if NET_2_0
                                Assert.IsFalse (client.DontFragment, "#A:DontFragment");
                                Assert.IsFalse (client.EnableBroadcast, "#A:EnableBroadcast");
                                //Assert.IsFalse (client.ExclusiveAddressUse, "#A:ExclusiveAddressUse");
                                //Assert.IsFalse (client.MulticastLoopback, "#A:MulticastLoopback");
                                //Assert.AreEqual (32, client.Ttl, "#A:Ttl");
-#endif
                                localEP = s.LocalEndPoint as IPEndPoint;
                                Assert.IsNotNull (localEP, "#A:Client:LocalEndpoint");
                                Assert.AreEqual (IPAddress.Loopback, localEP.Address, "#A:Client:LocalEndPoint/Address");
@@ -439,19 +375,15 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNotNull (s, "#B:Client");
                                Assert.AreEqual (AddressFamily.InterNetwork, s.AddressFamily, "#B:Client:AddressFamily");
                                Assert.IsTrue (s.Connected, "#B:Client:Connected");
-#if NET_2_0
                                Assert.IsTrue (s.IsBound, "#B:Client:IsBound");
-#endif
                                Assert.AreEqual (ProtocolType.Udp, s.ProtocolType, "#B:Client:ProtocolType");
                                Assert.AreEqual (SocketType.Dgram, s.SocketType, "#B:Client:SocketType");
                                Assert.IsTrue (client.Active, "#B:Active");
-#if NET_2_0
                                Assert.IsFalse (client.DontFragment, "#B:DontFragment");
                                Assert.IsFalse (client.EnableBroadcast, "#B:EnableBroadcast");
                                //Assert.IsFalse (client.ExclusiveAddressUse, "#B:ExclusiveAddressUse");
                                //Assert.IsFalse (client.MulticastLoopback, "#B:MulticastLoopback");
                                //Assert.AreEqual (32, client.Ttl, "#B:Ttl");
-#endif
                                localEP = s.LocalEndPoint as IPEndPoint;
                                Assert.IsNotNull (localEP, "#B:Client:LocalEndpoint");
                                Assert.AreEqual (IPAddress.Loopback, localEP.Address, "#B:Client:LocalEndPoint/Address");
@@ -525,11 +457,7 @@ namespace MonoTests.System.Net.Sockets {
                [Test] // JoinMulticastGroup (IPAddress)
                public void JoinMulticastGroup1_IPv6 ()
                {
-#if NET_2_0
                        if (!Socket.OSSupportsIPv6)
-#else
-                       if (!Socket.SupportsIPv6)
-#endif
                                Assert.Ignore ("IPv6 not enabled.");
 
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
@@ -546,20 +474,12 @@ namespace MonoTests.System.Net.Sockets {
                                try {
                                        client.JoinMulticastGroup ((IPAddress) null);
                                        Assert.Fail ("#1");
-#if NET_2_0
                                } catch (ArgumentNullException ex) {
                                        Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
                                        Assert.IsNull (ex.InnerException, "#3");
                                        Assert.IsNotNull (ex.Message, "#4");
                                        Assert.AreEqual ("multicastAddr", ex.ParamName, "#5");
                                }
-#else
-                               } catch (NullReferenceException ex) {
-                                       Assert.AreEqual (typeof (NullReferenceException), ex.GetType (), "#2");
-                                       Assert.IsNull (ex.InnerException, "#3");
-                                       Assert.IsNotNull (ex.Message, "#4");
-                               }
-#endif
                        }
                }
 
@@ -599,9 +519,7 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNull (ex.InnerException, "#4");
                                Assert.IsNotNull (ex.Message, "#5");
                                Assert.AreEqual (10022, ex.NativeErrorCode, "#6");
-#if NET_2_0
                                Assert.AreEqual (SocketError.InvalidArgument, ex.SocketErrorCode, "#7");
-#endif
                        } finally {
                                client.Close ();
                        }
@@ -624,9 +542,7 @@ namespace MonoTests.System.Net.Sockets {
                                        Assert.IsNull (ex.InnerException, "#4");
                                        Assert.IsNotNull (ex.Message, "#5");
                                        Assert.AreEqual (10045, ex.NativeErrorCode, "#6");
-#if NET_2_0
                                        Assert.AreEqual (SocketError.OperationNotSupported, ex.SocketErrorCode, "#7");
-#endif
                                }
                        }
                }
@@ -634,11 +550,7 @@ namespace MonoTests.System.Net.Sockets {
                [Test] // JoinMulticastGroup (In32, IPAddress)
                public void JoinMulticastGroup2_IPv6 ()
                {
-#if NET_2_0
                        if (!Socket.OSSupportsIPv6)
-#else
-                       if (!Socket.SupportsIPv6)
-#endif
                                Assert.Ignore ("IPv6 not enabled.");
 
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
@@ -667,11 +579,7 @@ namespace MonoTests.System.Net.Sockets {
                [Test] // JoinMulticastGroup (Int32, IPAddress)
                public void JoinMulticastGroup2_Socket_Closed ()
                {
-#if NET_2_0
                        if (!Socket.OSSupportsIPv6)
-#else
-                       if (!Socket.SupportsIPv6)
-#endif
                                Assert.Ignore ("IPv6 not enabled.");
 
                        IPAddress mcast_addr = null;
@@ -707,9 +615,7 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNull (ex.InnerException, "#4");
                                Assert.IsNotNull (ex.Message, "#5");
                                Assert.AreEqual (10022, ex.NativeErrorCode, "#6");
-#if NET_2_0
                                Assert.AreEqual (SocketError.InvalidArgument, ex.SocketErrorCode, "#7");
-#endif
                        } finally {
                                client.Close ();
                        }
@@ -732,11 +638,7 @@ namespace MonoTests.System.Net.Sockets {
                [Test] // JoinMulticastGroup (IPAddress, Int32)
                public void JoinMulticastGroup3_IPv6 ()
                {
-#if NET_2_0
                        if (!Socket.OSSupportsIPv6)
-#else
-                       if (!Socket.SupportsIPv6)
-#endif
                                Assert.Ignore ("IPv6 not enabled.");
 
                        IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
@@ -802,15 +704,12 @@ namespace MonoTests.System.Net.Sockets {
                                Assert.IsNull (ex.InnerException, "#4");
                                Assert.IsNotNull (ex.Message, "#5");
                                Assert.AreEqual (10022, ex.NativeErrorCode, "#6");
-#if NET_2_0
                                Assert.AreEqual (SocketError.InvalidArgument, ex.SocketErrorCode, "#7");
-#endif
                        } finally {
                                client.Close ();
                        }
                }
 
-#if NET_2_0
                [Test] // JoinMulticastGroup (IPAddress, IPAddress)
                public void JoinMulticastGroup4_IPv4 ()
                {
@@ -1160,7 +1059,6 @@ namespace MonoTests.System.Net.Sockets {
                }
                
                /* No test for Ttl default as it is platform dependent */
-#endif
 
                class MyUdpClient : UdpClient
                {