Intersect() public method

public Intersect ( IPermission target ) : IPermission
target IPermission
return IPermission
		public void IntersectWithBadPermission () 
		{
			FileDialogPermission p1 = new FileDialogPermission (FileDialogPermissionAccess.Open);
			EnvironmentPermission ep2 = new EnvironmentPermission (PermissionState.Unrestricted);
			FileDialogPermission p3 = (FileDialogPermission) p1.Intersect (ep2);
		}
		public void Intersect () 
		{
			// no intersection
			FileDialogPermission p1 = new FileDialogPermission (FileDialogPermissionAccess.Open);
			FileDialogPermission p2 = new FileDialogPermission (FileDialogPermissionAccess.Save);
			FileDialogPermission p3 = (FileDialogPermission) p1.Intersect (p2);
			Assert.IsNull (p3, "EP1 N EP2 == null");
			// intersection in open
			FileDialogPermission p4 = new FileDialogPermission (FileDialogPermissionAccess.Open);
			p3 = (FileDialogPermission) p4.Intersect (p1);
			Assert.AreEqual (FileDialogPermissionAccess.Open, p3.Access, "Intersect-Open");
			// intersection in save
			FileDialogPermission p5 = new FileDialogPermission (FileDialogPermissionAccess.Save);		
			p3 = (FileDialogPermission) p5.Intersect (p2);
			Assert.AreEqual (FileDialogPermissionAccess.Save, p3.Access, "Intersect-Save");
			// intersection in open and save
			FileDialogPermission p6 = new FileDialogPermission (FileDialogPermissionAccess.OpenSave);
			FileDialogPermission p7 = new FileDialogPermission (FileDialogPermissionAccess.OpenSave);
			p3 = (FileDialogPermission) p6.Intersect (p7);
			Assert.AreEqual (FileDialogPermissionAccess.OpenSave, p3.Access, "Intersect-AllAccess-OpenSave");
			Assert.IsTrue (p3.IsUnrestricted (), "Intersect-OpenSave-Unrestricted");
		}
		public void IntersectWithNull () 
		{
			FileDialogPermission p1 = new FileDialogPermission (FileDialogPermissionAccess.Open);
			FileDialogPermission p2 = null;
			FileDialogPermission p3 = (FileDialogPermission) p1.Intersect (p2);
			Assert.IsNull (p3, "P1 N null == null");
		}
		public void IntersectWithUnrestricted () 
		{
			FileDialogPermission p1 = new FileDialogPermission (PermissionState.Unrestricted);
			FileDialogPermission p2 = new FileDialogPermission (FileDialogPermissionAccess.Open);
			FileDialogPermission p3 = (FileDialogPermission) p1.Intersect (p2);
			Assert.IsTrue (!p3.IsUnrestricted (), "Unrestricted N P2 == P2");
			Assert.AreEqual (p2.ToXml ().ToString (), p3.ToXml ().ToString (), "Unrestricted N EP2 == EP2");
			p3 = (FileDialogPermission) p2.Intersect (p1);
			Assert.IsTrue (!p3.IsUnrestricted (), "P2 N Unrestricted == P2");
			Assert.AreEqual (p2.ToXml ().ToString (), p3.ToXml ().ToString (), "P2 N Unrestricted == P2");
		}
		public void Intersect () 
		{
			// no intersection
			FileDialogPermission p1 = new FileDialogPermission (FileDialogPermissionAccess.Open);
			FileDialogPermission p2 = new FileDialogPermission (FileDialogPermissionAccess.Save);
			FileDialogPermission p3 = (FileDialogPermission) p1.Intersect (p2);
			AssertNull ("EP1 N EP2 == null", p3);
			// intersection in open
			FileDialogPermission p4 = new FileDialogPermission (FileDialogPermissionAccess.Open);
			p3 = (FileDialogPermission) p4.Intersect (p1);
			AssertEquals ("Intersect-Open", FileDialogPermissionAccess.Open, p3.Access);
			// intersection in save
			FileDialogPermission p5 = new FileDialogPermission (FileDialogPermissionAccess.Save);		
			p3 = (FileDialogPermission) p5.Intersect (p2);
			AssertEquals ("Intersect-Save", FileDialogPermissionAccess.Save, p3.Access);
			// intersection in open and save
			FileDialogPermission p6 = new FileDialogPermission (FileDialogPermissionAccess.OpenSave);
			FileDialogPermission p7 = new FileDialogPermission (FileDialogPermissionAccess.OpenSave);
			p3 = (FileDialogPermission) p6.Intersect (p7);
			AssertEquals ("Intersect-AllAccess-OpenSave", FileDialogPermissionAccess.OpenSave, p3.Access);
			Assert ("Intersect-OpenSave-Unrestricted", p3.IsUnrestricted ());
		}