Intersect() публичный Метод

public Intersect ( IPermission target ) : IPermission
target IPermission
Результат IPermission
Пример #1
0
		public void IntersectWithBadPermission ()
		{
			RegistryPermission ep1 = new RegistryPermission (RegistryPermissionAccess.Read, keyLocalMachine);
			FileDialogPermission fdp2 = new FileDialogPermission (PermissionState.Unrestricted);
			RegistryPermission ep3 = (RegistryPermission)ep1.Intersect (fdp2);
		}
Пример #2
0
		public void Intersect_Subset ()
		{
			RegistryPermission ep1 = new RegistryPermission (RegistryPermissionAccess.AllAccess, keyLocalMachine);
			RegistryPermission ep2 = new RegistryPermission (RegistryPermissionAccess.Create, keyLocalMachineSubset);
			RegistryPermission ep3 = (RegistryPermission)ep1.Intersect (ep2);
			Assert.AreEqual (keyLocalMachine, ep3.GetPathList (RegistryPermissionAccess.Create), "Create");
			Assert.IsNull (ep3.GetPathList (RegistryPermissionAccess.Read), "Read");
			Assert.IsNull (ep3.GetPathList (RegistryPermissionAccess.Write), "Write");
		}
Пример #3
0
		public void IntersectWithUnrestricted ()
		{
			RegistryPermission ep1 = new RegistryPermission (PermissionState.Unrestricted);
			RegistryPermission ep2 = new RegistryPermission (RegistryPermissionAccess.Read, keyLocalMachine);
			RegistryPermission ep3 = (RegistryPermission)ep1.Intersect (ep2);
			Assert.IsTrue (!ep3.IsUnrestricted (), "Unrestricted N EP2 == EP2");
			Assert.AreEqual (ep2.ToXml ().ToString (), ep3.ToXml ().ToString (), "Unrestricted N EP2 == EP2");
			ep3 = (RegistryPermission)ep2.Intersect (ep1);
			Assert.IsTrue (!ep3.IsUnrestricted (), "EP2 N Unrestricted == EP2");
			Assert.AreEqual (ep2.ToXml ().ToString (), ep3.ToXml ().ToString (), "EP2 N Unrestricted == EP2");
		}
Пример #4
0
		public void Intersect ()
		{
			// no intersection
			RegistryPermission ep1 = new RegistryPermission (RegistryPermissionAccess.Write, keyCurrentUser);
			RegistryPermission ep2 = new RegistryPermission (RegistryPermissionAccess.Read, keyLocalMachine);
			RegistryPermission ep3 = (RegistryPermission)ep1.Intersect (ep2);
			Assert.IsNull (ep3, "EP1 N EP2 == null");
			// intersection in read
			RegistryPermission ep4 = new RegistryPermission (RegistryPermissionAccess.Read, keyLocalMachine);
			ep3 = (RegistryPermission)ep4.Intersect (ep2);
			Assert.AreEqual (keyLocalMachine, ep3.GetPathList (RegistryPermissionAccess.Read), "Intersect-Read");
			// intersection in write
			RegistryPermission ep5 = new RegistryPermission (RegistryPermissionAccess.Write, keyCurrentUser);
			ep3 = (RegistryPermission)ep5.Intersect (ep1);
			Assert.AreEqual (keyCurrentUser, ep3.GetPathList (RegistryPermissionAccess.Write), "Intersect-Write");
			// intersection in read and write
			RegistryPermission ep6 = new RegistryPermission (RegistryPermissionAccess.AllAccess, keyLocalMachine);
			RegistryPermission ep7 = new RegistryPermission (RegistryPermissionAccess.AllAccess, keyLocalMachine);
			ep3 = (RegistryPermission)ep6.Intersect (ep7);
			Assert.AreEqual (keyLocalMachine, ep3.GetPathList (RegistryPermissionAccess.Create), "Intersect-AllAccess-Create");
			Assert.AreEqual (keyLocalMachine, ep3.GetPathList (RegistryPermissionAccess.Read), "Intersect-AllAccess-Read");
			Assert.AreEqual (keyLocalMachine, ep3.GetPathList (RegistryPermissionAccess.Write), "Intersect-AllAccess-Write");
		}
Пример #5
0
		public void IntersectWithNull ()
		{
			RegistryPermission ep1 = new RegistryPermission (RegistryPermissionAccess.Read, keyLocalMachine);
			RegistryPermission ep2 = null;
			RegistryPermission ep3 = (RegistryPermission)ep1.Intersect (ep2);
			Assert.IsNull (ep3, "EP1 N null == null");
		}