IsSubsetOf() public method

public IsSubsetOf ( IPermission target ) : bool
target IPermission
return bool
Exemplo n.º 1
0
		private ZoneIdentityPermission BasicTestZone (SecurityZone zone, bool special)
		{
			ZoneIdentityPermission zip = new ZoneIdentityPermission (zone);
			Assert.AreEqual (zone, zip.SecurityZone, "SecurityZone");
			
			ZoneIdentityPermission copy = (ZoneIdentityPermission) zip.Copy ();
			Assert.IsTrue (Same (zip, copy), "Equals-Copy");
			Assert.IsTrue (zip.IsSubsetOf (copy), "IsSubset-1");
			Assert.IsTrue (copy.IsSubsetOf (zip), "IsSubset-2");
			if (special) {
				Assert.IsFalse (zip.IsSubsetOf (null), "IsSubset-Null");
			}
			
			IPermission intersect = zip.Intersect (copy);
			if (special) {
				Assert.IsTrue (intersect.IsSubsetOf (zip), "IsSubset-3");
				Assert.IsFalse (Object.ReferenceEquals (zip, intersect), "!ReferenceEquals1");
				Assert.IsTrue (intersect.IsSubsetOf (copy), "IsSubset-4");
				Assert.IsFalse (Object.ReferenceEquals (copy, intersect), "!ReferenceEquals2");
			}

			Assert.IsNull (zip.Intersect (null), "Intersect with null");

			intersect = zip.Intersect (new ZoneIdentityPermission (PermissionState.None));
			Assert.IsNull (intersect, "Intersect with PS.None");

			// note: can't be tested with PermissionState.Unrestricted

			// XML roundtrip
			SecurityElement se = zip.ToXml ();
			copy.FromXml (se);
			Assert.IsTrue (Same (zip, copy), "Equals-Xml");

			return zip;
		}
Exemplo n.º 2
0
		public void IsSubsetOf_DifferentPermissions ()
		{
			ZoneIdentityPermission a = new ZoneIdentityPermission (SecurityZone.Trusted);
			SecurityPermission b = new SecurityPermission (PermissionState.None);
			a.IsSubsetOf (b);
		}