コード例 #1
0
		public void NullConstructor ()
		{
			PermissionRequestEvidence pre = new PermissionRequestEvidence (null, null, null);
			Assert.IsNull (pre.RequestedPermissions, "Requested");
			Assert.IsNull (pre.OptionalPermissions, "Optional");
			Assert.IsNull (pre.DeniedPermissions, "Denied");
			string expected = AdjustNewLine ("<System.Security.Policy.PermissionRequestEvidence version=\"1\"/>\r\n");
			Assert.AreEqual (expected, pre.ToString (), "ToString");
		}
コード例 #2
0
		public void Copy () 
		{
			PermissionSet ps1 = new PermissionSet (PermissionState.None);
			PermissionSet ps2 = new PermissionSet (PermissionState.Unrestricted);
			PermissionRequestEvidence pre = new PermissionRequestEvidence (ps2, ps1, ps2);
			PermissionRequestEvidence copy = pre.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (pre, copy), "!ReferenceEquals");
			Assert.IsTrue (copy.RequestedPermissions.IsUnrestricted (), "Requested");
			Assert.IsFalse (copy.OptionalPermissions.IsUnrestricted (), "Optional");
			Assert.IsTrue (copy.DeniedPermissions.IsUnrestricted (), "Denied");
			Assert.IsFalse (Object.ReferenceEquals (ps2, copy.RequestedPermissions), "!ReferenceEquals-RequestedPermissions");
			Assert.IsFalse (Object.ReferenceEquals (ps1, copy.OptionalPermissions), "!ReferenceEquals-OptionalPermissions");
			Assert.IsFalse (Object.ReferenceEquals (ps2, copy.DeniedPermissions), "!ReferenceEquals-DeniedPermissions");
			Assert.IsFalse (Object.ReferenceEquals (pre.RequestedPermissions, copy.RequestedPermissions), "!ReferenceEquals-Copy-RequestedPermissions");
			Assert.IsFalse (Object.ReferenceEquals (pre.OptionalPermissions, copy.OptionalPermissions), "!ReferenceEquals-Copy-OptionalPermissions");
			Assert.IsFalse (Object.ReferenceEquals (pre.DeniedPermissions, copy.DeniedPermissions), "!ReferenceEquals-Copy-DeniedPermissions");
			string expected = AdjustNewLine ("<System.Security.Policy.PermissionRequestEvidence version=\"1\">\r\n   <Request>\r\n      <PermissionSet class=\"System.Security.PermissionSet\"\r\n                     version=\"1\"\r\n                     Unrestricted=\"true\"/>\r\n   </Request>\r\n   <Optional>\r\n      <PermissionSet class=\"System.Security.PermissionSet\"\r\n                     version=\"1\"/>\r\n   </Optional>\r\n   <Denied>\r\n      <PermissionSet class=\"System.Security.PermissionSet\"\r\n                     version=\"1\"\r\n                     Unrestricted=\"true\"/>\r\n   </Denied>\r\n</System.Security.Policy.PermissionRequestEvidence>\r\n");
			Assert.AreEqual (expected, pre.ToString (), "ToString");
			Assert.AreEqual (pre.ToString (), copy.ToString (), "ToString-Copy");
		}
コード例 #3
0
		public void Constructor1 () 
		{
			PermissionSet ps = new PermissionSet (PermissionState.None);
			PermissionRequestEvidence pre = new PermissionRequestEvidence (ps, ps, ps);
			Assert.IsFalse (pre.RequestedPermissions.IsUnrestricted (), "Requested");
			Assert.IsFalse (pre.OptionalPermissions.IsUnrestricted (), "Optional");
			Assert.IsFalse (pre.DeniedPermissions.IsUnrestricted (), "Denied");
			Assert.IsFalse (Object.ReferenceEquals (ps, pre.RequestedPermissions), "!ReferenceEquals-RequestedPermissions");
			Assert.IsFalse (Object.ReferenceEquals (ps, pre.OptionalPermissions), "!ReferenceEquals-OptionalPermissions");
			Assert.IsFalse (Object.ReferenceEquals (ps, pre.DeniedPermissions), "!ReferenceEquals-DeniedPermissions");
			string expected = AdjustNewLine ("<System.Security.Policy.PermissionRequestEvidence version=\"1\">\r\n   <Request>\r\n      <PermissionSet class=\"System.Security.PermissionSet\"\r\n                     version=\"1\"/>\r\n   </Request>\r\n   <Optional>\r\n      <PermissionSet class=\"System.Security.PermissionSet\"\r\n                     version=\"1\"/>\r\n   </Optional>\r\n   <Denied>\r\n      <PermissionSet class=\"System.Security.PermissionSet\"\r\n                     version=\"1\"/>\r\n   </Denied>\r\n</System.Security.Policy.PermissionRequestEvidence>\r\n");
			Assert.AreEqual (expected, pre.ToString (), "ToString");
		}