public void Intersect_None()
        {
            EventLogPermission elp1 = new EventLogPermission(PermissionState.None);
            EventLogPermission elp2 = new EventLogPermission(PermissionState.None);
            // 1. None N None
            EventLogPermission result = (EventLogPermission)elp1.Intersect(elp2);

            Assert.IsNull(result, "Empty N Empty");
            // 2. None N Entry
            elp2.PermissionEntries.Add(new EventLogPermissionEntry(EventLogPermissionAccess.None, "localhost"));
            result = (EventLogPermission)elp1.Intersect(elp2);
            Assert.IsNull(result, "Empty N Entry");
            // 3. Entry N None
            result = (EventLogPermission)elp2.Intersect(elp1);
            Assert.IsNull(result, "Entry N Empty");
        }
        public void Intersect_Null()
        {
            EventLogPermission elp = new EventLogPermission(PermissionState.None);

            // No intersection with null
            Assert.IsNull(elp.Intersect(null), "None N null");
        }
        public void Intersect_Unrestricted()
        {
            // Intersection with unrestricted == Copy
            // a. source (this) is unrestricted
            EventLogPermission elp1 = new EventLogPermission(PermissionState.Unrestricted);
            EventLogPermission elp2 = new EventLogPermission(PermissionState.None);

            // 1. Unrestricted N None
            EventLogPermission result = (EventLogPermission)elp1.Intersect(elp2);

            Assert.IsFalse(result.IsUnrestricted(), "(Unrestricted N None).IsUnrestricted");
            Assert.AreEqual(0, result.PermissionEntries.Count, "(Unrestricted N None).Count");

            // 2. None N Unrestricted
            result = (EventLogPermission)elp2.Intersect(elp1);
            Assert.IsFalse(result.IsUnrestricted(), "(None N Unrestricted).IsUnrestricted");
            Assert.AreEqual(0, result.PermissionEntries.Count, "(None N Unrestricted).Count");

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

            // 4. Unrestricted N Entry
            elp2.PermissionEntries.Add(new EventLogPermissionEntry(EventLogPermissionAccess.None, "localhost"));
            result = (EventLogPermission)elp1.Intersect(elp2);
            Assert.IsFalse(result.IsUnrestricted(), "(Unrestricted N Entry).IsUnrestricted");
            Assert.AreEqual(1, result.PermissionEntries.Count, "(Unrestricted N Entry).Count");

            // 5. Entry N Unrestricted
            result = (EventLogPermission)elp2.Intersect(elp1);
            Assert.IsFalse(result.IsUnrestricted(), "(Entry N Unrestricted).IsUnrestricted");
            Assert.AreEqual(1, result.PermissionEntries.Count, "(Entry N Unrestricted).Count");

            // 6. Unrestricted N Unrestricted
            elp1.PermissionEntries.Add(new EventLogPermissionEntry(EventLogPermissionAccess.None, "localhost"));
            result = (EventLogPermission)elp1.Intersect(elp1);
            Assert.IsTrue(result.IsUnrestricted(), "(Unrestricted N Unrestricted).IsUnrestricted");
            Assert.AreEqual(1, result.PermissionEntries.Count, "(Unrestricted N Unrestricted).Count");
        }
        public void Intersect_BadPermission()
        {
            EventLogPermission elp1 = new EventLogPermission(PermissionState.Unrestricted);

            elp1.Intersect(new SecurityPermission(SecurityPermissionFlag.Assertion));
        }