Esempio n. 1
0
        public static void PermissionRequestEvidenceCallMethods()
        {
            PermissionSet             ps  = new PermissionSet(new PermissionState());
            PermissionRequestEvidence pre = new PermissionRequestEvidence(ps, ps, ps);
            PermissionRequestEvidence obj = pre.Copy();
            string          str           = ps.ToString();
            SecurityElement se            = new SecurityElement("");

            ps.FromXml(se);
            se = ps.ToXml();
        }
		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");
		}