Merge pull request #601 from knocte/sock_improvements
[mono.git] / mcs / class / System / Test / System.Net / WebPermissionAttributeTest.cs
index 2814448e47d10b9b177650ebba3b58c879d190e0..77c4b75c0980af7bd888d2650d67089f768aeb25 100644 (file)
@@ -1,4 +1,4 @@
-//
+//
 // WebPermissionAttributeTest.cs - NUnit Test Cases for WebPermissionAttribute
 //
 // Author:
@@ -36,6 +36,9 @@ using System.Text.RegularExpressions;
 namespace MonoTests.System.Net {
 
        [TestFixture]
+#if MOBILE
+       [Ignore ("CAS is not supported and parts will be linked away")]
+#endif
        public class WebPermissionAttributeTest {
 
                [Test]
@@ -70,14 +73,6 @@ namespace MonoTests.System.Net {
                        Assert.AreEqual (SecurityAction.RequestOptional, a.Action, "Action=RequestOptional");
                        a.Action = SecurityAction.RequestRefuse;
                        Assert.AreEqual (SecurityAction.RequestRefuse, a.Action, "Action=RequestRefuse");
-#if NET_2_0
-                       a.Action = SecurityAction.DemandChoice;
-                       Assert.AreEqual (SecurityAction.DemandChoice, a.Action, "Action=DemandChoice");
-                       a.Action = SecurityAction.InheritanceDemandChoice;
-                       Assert.AreEqual (SecurityAction.InheritanceDemandChoice, a.Action, "Action=InheritanceDemandChoice");
-                       a.Action = SecurityAction.LinkDemandChoice;
-                       Assert.AreEqual (SecurityAction.LinkDemandChoice, a.Action, "Action=LinkDemandChoice");
-#endif
                }
 
                [Test]
@@ -100,6 +95,7 @@ namespace MonoTests.System.Net {
                        Assert.IsFalse (wp.IsUnrestricted (), "!IsUnrestricted");
                }
 
+#if NET_2_0
                [Test]
                public void Accept_Null ()
                {
@@ -108,6 +104,31 @@ namespace MonoTests.System.Net {
                        Assert.IsNull (a.Accept, "Accept");
                        Assert.IsNull (a.Connect, "Connect");
                }
+#else
+
+               [Test]
+               // Strangely, although you can set Accept to value of null, you cannot
+               // then examine the value without throwing a NullRef
+               [ExpectedException (typeof (NullReferenceException))]
+               public void Accept_Null ()
+               {
+                       WebPermissionAttribute a = new WebPermissionAttribute (SecurityAction.Assert);
+                       a.Accept = null; // legal
+                       Assert.IsNull (a.Connect, "Connect");
+               }
+
+               [Test]
+               // Strangely, although you can set Accept to value of null, you cannot
+               // then examine the value without throwing a NullRef
+               [ExpectedException (typeof (NullReferenceException))]
+               public void Accept_Null2 ()
+               {
+                       WebPermissionAttribute a = new WebPermissionAttribute (SecurityAction.Assert);
+                       a.Accept = null; // legal
+                       Assert.IsNull (a.Accept, "Accept");
+               }
+
+#endif
 
                [Test]
                [ExpectedException (typeof (ArgumentException))]
@@ -151,6 +172,7 @@ namespace MonoTests.System.Net {
                        a.AcceptPattern = "\\";
                }
 
+#if NET_2_0
                [Test]
                public void AcceptPattern ()
                {
@@ -159,6 +181,7 @@ namespace MonoTests.System.Net {
                        Assert.AreEqual ("\b(?", a.AcceptPattern, "AcceptPattern");
                        Assert.IsNull (a.ConnectPattern, "ConnectPattern");
                }
+#endif
 
                [Test]
                [ExpectedException (typeof (ArgumentException))]
@@ -178,6 +201,7 @@ namespace MonoTests.System.Net {
                        a.Accept = "\\";
                }
 
+#if NET_2_0
                [Test]
                public void Connect_Null ()
                {
@@ -186,6 +210,25 @@ namespace MonoTests.System.Net {
                        Assert.IsNull (a.Accept, "Accept");
                        Assert.IsNull (a.Connect, "Connect");
                }
+#else
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void Connect_Null ()
+               {
+                       WebPermissionAttribute a = new WebPermissionAttribute (SecurityAction.Assert);
+                       a.Connect = null; // legal
+                       Assert.IsNull (a.Accept, "Accept");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void Connect_Null2 ()
+               {
+                       WebPermissionAttribute a = new WebPermissionAttribute (SecurityAction.Assert);
+                       a.Connect = null; // legal
+                       Assert.IsNull (a.Connect, "Connect");
+               }
+#endif
 
                [Test]
                [ExpectedException (typeof (ArgumentException))]
@@ -205,6 +248,7 @@ namespace MonoTests.System.Net {
                        a.Connect = null;
                }
 
+#if NET_2_0
                [Test]
                public void Connect ()
                {
@@ -213,6 +257,7 @@ namespace MonoTests.System.Net {
                        Assert.IsNull (a.Accept, "Accept");
                        Assert.AreEqual ("/", a.Connect, "Connect");
                }
+#endif
 
                [Test]
                [ExpectedException (typeof (ArgumentNullException))]
@@ -231,6 +276,7 @@ namespace MonoTests.System.Net {
                        a.ConnectPattern = "\\";
                }
 
+#if NET_2_0
                [Test]
                public void ConnectPattern ()
                {
@@ -239,6 +285,7 @@ namespace MonoTests.System.Net {
                        Assert.IsNull (a.AcceptPattern, "AcceptPattern");
                        Assert.AreEqual ("\b(?", a.ConnectPattern, "ConnectPattern");
                }
+#endif
 
                [Test]
                [ExpectedException (typeof (ArgumentException))]
@@ -258,6 +305,7 @@ namespace MonoTests.System.Net {
                        a.Connect = "\\";
                }
 
+#if NET_2_0
                [Test]
                public void CreatePermission_InvalidRegex ()
                {
@@ -267,6 +315,7 @@ namespace MonoTests.System.Net {
                        WebPermission wp = (WebPermission) a.CreatePermission ();
                        Assert.IsNotNull (wp, "CreatePermission");
                }
+#endif
 
                [Test]
                public void Attributes ()