-//
+//
// WebPermissionAttributeTest.cs - NUnit Test Cases for WebPermissionAttribute
//
// Author:
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]
Assert.IsFalse (wp.IsUnrestricted (), "!IsUnrestricted");
}
+#if NET_2_0
[Test]
public void Accept_Null ()
{
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))]
a.AcceptPattern = "\\";
}
+#if NET_2_0
[Test]
public void AcceptPattern ()
{
Assert.AreEqual ("\b(?", a.AcceptPattern, "AcceptPattern");
Assert.IsNull (a.ConnectPattern, "ConnectPattern");
}
+#endif
[Test]
[ExpectedException (typeof (ArgumentException))]
a.Accept = "\\";
}
+#if NET_2_0
[Test]
public void Connect_Null ()
{
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))]
a.Connect = null;
}
+#if NET_2_0
[Test]
public void Connect ()
{
Assert.IsNull (a.Accept, "Accept");
Assert.AreEqual ("/", a.Connect, "Connect");
}
+#endif
[Test]
[ExpectedException (typeof (ArgumentNullException))]
a.ConnectPattern = "\\";
}
+#if NET_2_0
[Test]
public void ConnectPattern ()
{
Assert.IsNull (a.AcceptPattern, "AcceptPattern");
Assert.AreEqual ("\b(?", a.ConnectPattern, "ConnectPattern");
}
+#endif
[Test]
[ExpectedException (typeof (ArgumentException))]
a.Connect = "\\";
}
+#if NET_2_0
[Test]
public void CreatePermission_InvalidRegex ()
{
WebPermission wp = (WebPermission) a.CreatePermission ();
Assert.IsNotNull (wp, "CreatePermission");
}
+#endif
[Test]
public void Attributes ()