public void PermissionState_None ()
		{
			PermissionState ps = PermissionState.None;
			PrintingPermission pp = new PrintingPermission (ps);
			Assert.AreEqual (PrintingPermissionLevel.NoPrinting, pp.Level, "Level");
			Assert.IsFalse (pp.IsUnrestricted (), "IsUnrestricted");

			SecurityElement se = pp.ToXml ();
			// only class and version are present
			Assert.AreEqual ("NoPrinting", se.Attribute ("Level"), "Xml-Level");
			Assert.IsNull (se.Children, "Xml-Children");

			PrintingPermission copy = (PrintingPermission)pp.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (pp, copy), "ReferenceEquals");
			Assert.AreEqual (pp.Level, copy.Level, "Level");
			Assert.AreEqual (pp.IsUnrestricted (), copy.IsUnrestricted (), "IsUnrestricted ()");
		}
Exemple #2
0
        public override IPermission Union(IPermission target)
        {
            PrintingPermission pp = Cast(target);

            if (pp == null)
            {
                return(new PrintingPermission(_Level));
            }
            if (IsUnrestricted() || pp.IsUnrestricted())
            {
                return(new PrintingPermission(PermissionState.Unrestricted));
            }
            if (IsEmpty() && pp.IsEmpty())
            {
                return(null);
            }

            PrintingPermissionLevel level = (_Level > pp.Level) ? _Level : pp.Level;

            return(new PrintingPermission(level));
        }