public void Intersect_BadPermission ()
		{
			PerformanceCounterPermission pcp1 = new PerformanceCounterPermission (PermissionState.Unrestricted);
			pcp1.Intersect (new SecurityPermission (SecurityPermissionFlag.Assertion));
		}
		public void Intersect_None ()
		{
			PerformanceCounterPermission pcp1 = new PerformanceCounterPermission (PermissionState.None);
			PerformanceCounterPermission pcp2 = new PerformanceCounterPermission (PermissionState.None);
			// 1. None N None
			PerformanceCounterPermission result = (PerformanceCounterPermission)pcp1.Intersect (pcp2);
			Assert.IsNull (result, "Empty N Empty");
			// 2. None N Entry
			pcp2.PermissionEntries.Add (new PerformanceCounterPermissionEntry (PerformanceCounterPermissionAccess.None, "localhost", String.Empty));
			result = (PerformanceCounterPermission)pcp1.Intersect (pcp2);
			Assert.IsNull (result, "Empty N Entry");
			// 3. Entry N None
			result = (PerformanceCounterPermission)pcp2.Intersect (pcp1);
			Assert.IsNull (result, "Entry N Empty");
		}
		public void Intersect_Unrestricted ()
		{
			// Intersection with unrestricted == Copy
			// a. source (this) is unrestricted
			PerformanceCounterPermission pcp1 = new PerformanceCounterPermission (PermissionState.Unrestricted);
			PerformanceCounterPermission pcp2 = new PerformanceCounterPermission (PermissionState.None);

			// 1. Unrestricted N None
			PerformanceCounterPermission result = (PerformanceCounterPermission)pcp1.Intersect (pcp2);
			Assert.IsFalse (result.IsUnrestricted (), "(Unrestricted N None).IsUnrestricted");
			Assert.AreEqual (0, result.PermissionEntries.Count, "(Unrestricted N None).Count");

			// 2. None N Unrestricted
			result = (PerformanceCounterPermission)pcp2.Intersect (pcp1);
			Assert.IsFalse (result.IsUnrestricted (), "(None N Unrestricted).IsUnrestricted");
			Assert.AreEqual (0, result.PermissionEntries.Count, "(None N Unrestricted).Count");

			// 3. Unrestricted N Unrestricted
			result = (PerformanceCounterPermission)pcp1.Intersect (pcp1);
			Assert.IsTrue (result.IsUnrestricted (), "(Unrestricted N Unrestricted).IsUnrestricted");
			Assert.AreEqual (0, result.PermissionEntries.Count, "(Unrestricted N Unrestricted).Count");

			// 4. Unrestricted N Entry
			pcp2.PermissionEntries.Add (new PerformanceCounterPermissionEntry (PerformanceCounterPermissionAccess.None, "localhost", String.Empty));
			result = (PerformanceCounterPermission)pcp1.Intersect (pcp2);
			Assert.IsFalse (result.IsUnrestricted (), "(Unrestricted N Entry).IsUnrestricted");
			Assert.AreEqual (1, result.PermissionEntries.Count, "(Unrestricted N Entry).Count");

			// 5. Entry N Unrestricted
			result = (PerformanceCounterPermission)pcp2.Intersect (pcp1);
			Assert.IsFalse (result.IsUnrestricted (), "(Entry N Unrestricted).IsUnrestricted");
			Assert.AreEqual (1, result.PermissionEntries.Count, "(Entry N Unrestricted).Count");

			// 6. Unrestricted N Unrestricted
			pcp1.PermissionEntries.Add (new PerformanceCounterPermissionEntry (PerformanceCounterPermissionAccess.None, "localhost", String.Empty));
			result = (PerformanceCounterPermission)pcp1.Intersect (pcp1);
			Assert.IsTrue (result.IsUnrestricted (), "(Unrestricted N Unrestricted).IsUnrestricted");
			Assert.AreEqual (1, result.PermissionEntries.Count, "(Unrestricted N Unrestricted).Count");
		}
		public void Intersect_Null ()
		{
			PerformanceCounterPermission pcp = new PerformanceCounterPermission (PermissionState.None);
			// No intersection with null
			Assert.IsNull (pcp.Intersect (null), "None N null");
		}