public void FromXml_WrongVersion()
        {
            EventLogPermission elp = new EventLogPermission(PermissionState.None);
            SecurityElement    se  = elp.ToXml();

            se.Attributes.Remove("version");
            se.Attributes.Add("version", "2");
            elp.FromXml(se);
        }
        public void FromXml_NoVersion()
        {
            EventLogPermission elp = new EventLogPermission(PermissionState.None);
            SecurityElement    se  = elp.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            elp.FromXml(w);
        }
        public void FromXml_WrongTagCase()
        {
            EventLogPermission elp = new EventLogPermission(PermissionState.None);
            SecurityElement    se  = elp.ToXml();

            se.Tag = "IPERMISSION"; // instead of IPermission
            elp.FromXml(se);
            // note: normally IPermission classes (in corlib) DO care about the
            // IPermission tag
        }
        public void FromXml_NoClass()
        {
            EventLogPermission elp = new EventLogPermission(PermissionState.None);
            SecurityElement    se  = elp.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("version", se.Attribute("version"));
            elp.FromXml(w);
            // doesn't even care of the class attribute presence
        }
        public void FromXml_WrongClass()
        {
            EventLogPermission elp = new EventLogPermission(PermissionState.None);
            SecurityElement    se  = elp.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", "Wrong" + se.Attribute("class"));
            w.AddAttribute("version", se.Attribute("version"));
            elp.FromXml(w);
            // doesn't care of the class name at that stage
            // anyway the class has already be created so...
        }
        public void PermissionState_Unrestricted()
        {
            PermissionState    ps  = PermissionState.Unrestricted;
            EventLogPermission elp = new EventLogPermission(ps);

            Assert.AreEqual(0, elp.PermissionEntries.Count, "PermissionEntries");
            Assert.IsTrue(elp.IsUnrestricted(), "IsUnrestricted");

            SecurityElement se = elp.ToXml();

            // only class and version are present
            Assert.AreEqual("true", se.Attribute("Unrestricted"), "Xml-Unrestricted");
            Assert.IsNull(se.Children, "Xml-Children");

            EventLogPermission copy = (EventLogPermission)elp.Copy();

            Assert.IsFalse(Object.ReferenceEquals(elp, copy), "ReferenceEquals");
            Assert.AreEqual(elp.PermissionEntries.Count, copy.PermissionEntries.Count, "copy-PermissionEntries");
            Assert.AreEqual(elp.IsUnrestricted(), copy.IsUnrestricted(), "copy-IsUnrestricted ()");
        }