Intersect() public method

public Intersect ( IPermission target ) : IPermission
target IPermission
return IPermission
		private void CommonTests (AspNetHostingPermission p)
		{
			Assert.IsNotNull (p.Copy (), "Copy");
			SecurityElement se = p.ToXml ();
			Assert.IsNotNull (se, "ToXml");
			p.FromXml (se);
			Assert.IsNotNull (p.Intersect (p), "Intersect");
			Assert.IsTrue (p.IsSubsetOf (p), "IsSubsetOf");
			Assert.IsNotNull (p.Union (p), "Union");
		}
		public void IsSubset_Self ()
		{
			AspNetHostingPermission anhp = new AspNetHostingPermission (PermissionState.None);
			foreach (AspNetHostingPermissionLevel ppl in AllLevel) {
				anhp.Level = ppl;
				AspNetHostingPermission result = (AspNetHostingPermission)anhp.Intersect (anhp);
				Assert.IsTrue (anhp.IsSubsetOf (anhp), ppl.ToString ());
			}
		}
		public void Intersect_Unrestricted ()
		{
			// Intersection with unrestricted == Copy
			// a. source (this) is unrestricted
			AspNetHostingPermission sp1 = new AspNetHostingPermission (PermissionState.Unrestricted);
			AspNetHostingPermission sp2 = new AspNetHostingPermission (PermissionState.None);
			foreach (AspNetHostingPermissionLevel ppl in AllLevel) {
				sp2.Level = ppl;
				AspNetHostingPermission result = (AspNetHostingPermission)sp1.Intersect (sp2);
				Assert.AreEqual (sp2.Level, result.Level, "target " + ppl.ToString ());
			}
			// b. destination (target) is unrestricted
			foreach (AspNetHostingPermissionLevel ppl in AllLevel) {
				sp2.Level = ppl;
				AspNetHostingPermission result = (AspNetHostingPermission)sp2.Intersect (sp1);
				Assert.AreEqual (sp2.Level, result.Level, "source " + ppl.ToString ());
			}
		}
		public void Intersect_Self ()
		{
			AspNetHostingPermission anhp = new AspNetHostingPermission (PermissionState.None);
			foreach (AspNetHostingPermissionLevel ppl in AllLevel) {
				anhp.Level = ppl;
				AspNetHostingPermission result = (AspNetHostingPermission)anhp.Intersect (anhp);
				Assert.AreEqual (ppl, result.Level, ppl.ToString ());
			}
		}
		public void Intersect_None ()
		{
			AspNetHostingPermission sp1 = new AspNetHostingPermission (PermissionState.None);
			AspNetHostingPermission sp2 = new AspNetHostingPermission (PermissionState.None);
			foreach (AspNetHostingPermissionLevel ppl in AllLevel) {
				sp2.Level = ppl;
				// 1. Intersect None with ppl
				AspNetHostingPermission result = (AspNetHostingPermission)sp1.Intersect (sp2);
				Assert.AreEqual (AspNetHostingPermissionLevel.None, result.Level, "None N " + ppl.ToString ());
				// 2. Intersect ppl with None
				result = (AspNetHostingPermission)sp2.Intersect (sp1);
				Assert.AreEqual (AspNetHostingPermissionLevel.None, result.Level, ppl.ToString () + "N None");
			}
		}
		public void Intersect_Null ()
		{
			AspNetHostingPermission anhp = new AspNetHostingPermission (PermissionState.None);
			// No intersection with null
			foreach (AspNetHostingPermissionLevel ppl in AllLevel) {
				anhp.Level = ppl;
				IPermission p = anhp.Intersect (null);
				Assert.IsNull (p, ppl.ToString ());
			}
		}
		public void Intersect_Null ()
		{
			AspNetHostingPermission anhp = new AspNetHostingPermission (PermissionState.None);
			// No intersection with null
			foreach (AspNetHostingPermissionLevel ppl in AllLevel) {
				anhp.Level = ppl;
				IPermission p = anhp.Intersect (null);
#if ! NET_2_0
				if (p != null)
					Assert.Ignore ("Behaviour changed in FX 1.1 SP1");
#endif
				Assert.IsNull (p, ppl.ToString ());
			}
		}