示例#1
0
        public void ToXml()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            Assert.AreEqual("IMembershipCondition", se.Tag, "Tag");
            Assert.IsTrue(se.Attribute("class").StartsWith("System.Security.Policy.ApplicationMembershipCondition"), "class");
            Assert.AreEqual("1", se.Attribute("version"), "version");
            Assert.AreEqual("true", se.Attribute("LookAtDir"), "LookAtDir");
            Assert.AreEqual(se.ToString(), app.ToXml(null).ToString(), "ToXml(null)");
            Assert.AreEqual(se.ToString(), app.ToXml(PolicyLevel.CreateAppDomainLevel()).ToString(), "ToXml(PolicyLevel)");
        }
示例#2
0
        public void FromXml()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            app.FromXml(se);
        }
示例#3
0
        public void FromXml_PolicyLevelNull()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            app.FromXml(se, null);
        }
示例#4
0
        public void FromXml_NonBooleanLookAtDir()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            w.AddAttribute("version", se.Attribute("version"));
            w.AddAttribute("LookAtDir", "Maybe");              // not (generally) a boolean ;)

            ApplicationMembershipCondition app2 = new ApplicationMembershipCondition();

            app2.FromXml(w);

            se = app2.ToXml();
            Assert.IsNull(se.Attribute("LookAtDir"), "LookAtDir");
            // LookAtDir isn't part of the Equals computation
            Assert.IsTrue(app2.Equals(app), "Equals-1");
            Assert.IsTrue(app.Equals(app2), "Equals-2");

            ApplicationMembershipCondition app3 = (ApplicationMembershipCondition)app2.Copy();

            se = app3.ToXml();
            // LookAtDir isn't copied either
            Assert.AreEqual("true", se.Attribute("LookAtDir"), "Copy-LookAtDir");
        }
示例#5
0
        public void FromXml_InvalidClass()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            se.Attributes ["class"] = "Hello world";
            app.FromXml(se);
        }
示例#6
0
        public void FromXml_WrongTagCase()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            se.Tag = "IMEMBERSHIPCONDITION";             // insteapp of IMembershipCondition
            app.FromXml(se);
        }
示例#7
0
        public void FromXml_InvalidTag()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            se.Tag = "IMonoship";
            app.FromXml(se);
        }
示例#8
0
        public void FromXml_NoVersion()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            app.FromXml(w);
        }
示例#9
0
        public void FromXml_NoClass()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("version", se.Attribute("version"));
            app.FromXml(w);
            // doesn't even care of the class attribute presence
        }
示例#10
0
        public void FromXml_InvalidVersion()
        {
            ApplicationMembershipCondition app = new ApplicationMembershipCondition();
            SecurityElement se = app.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            w.AddAttribute("version", "2");
            app.FromXml(w);
            // doesn't seems to care about the version number!
        }