public static void SiteMembershipConditionCallMethods()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("test");
            bool check = smc.Check(new Evidence());
            IMembershipCondition obj = smc.Copy();

            check = smc.Equals(new object());
            int             hash = smc.GetHashCode();
            string          str  = smc.ToString();
            SecurityElement se   = new SecurityElement("");
            PolicyLevel     pl   = (PolicyLevel)FormatterServices.GetUninitializedObject(typeof(PolicyLevel));

            smc.FromXml(se);
            smc.FromXml(se, pl);
            se = smc.ToXml();
            se = smc.ToXml(pl);
        }
예제 #2
0
        public void ToXml_Null()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("*.go-mono.com");
            // no ArgumentNullException here
            SecurityElement se = smc.ToXml(null);

            Assert.IsNotNull(se, "ToXml(null)");
        }
예제 #3
0
        public void ToXml_PolicyLevel()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("*.go-mono.com");
            SecurityElement         se  = smc.ToXml();
            string s = smc.ToXml().ToString();
            // is it accepted for all policy levels ?
            IEnumerator e = SecurityManager.PolicyHierarchy();

            while (e.MoveNext())
            {
                PolicyLevel             pl  = e.Current as PolicyLevel;
                SiteMembershipCondition spl = new SiteMembershipCondition("*");
                spl.FromXml(se, pl);
                Assert.AreEqual(s, spl.ToXml(pl).ToString(), "ToXml(PolicyLevel='" + pl.Label + "')");
            }
            // yes!
        }
예제 #4
0
        public void FromXml_InvalidVersion()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("*.go-mono.com");
            SecurityElement         se  = smc.ToXml();

            se.Attributes ["version"] = "2";
            smc.FromXml(se);
        }
예제 #5
0
        public void FromXml_InvalidClass()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("*.go-mono.com");
            SecurityElement         se  = smc.ToXml();

            se.Attributes ["class"] = "Hello world";
            smc.FromXml(se);
        }
예제 #6
0
        public void FromXml_InvalidTag()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("*.go-mono.com");
            SecurityElement         se  = smc.ToXml();

            se.Tag = "IMonoship";
            smc.FromXml(se);
        }
예제 #7
0
        public static void SiteMembershipConditionCallMethods()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("test");
            bool check = smc.Check(new Evidence());
            IMembershipCondition obj = smc.Copy();

            check = smc.Equals(new object());
            int             hash = smc.GetHashCode();
            string          str  = smc.ToString();
            SecurityElement se   = new SecurityElement("");
            PolicyLevel     pl   = (PolicyLevel)Activator.CreateInstance(typeof(PolicyLevel), true);

            smc.FromXml(se);
            smc.FromXml(se, pl);
            se = smc.ToXml();
            se = smc.ToXml(pl);
        }
예제 #8
0
        public void FromXml_NoVersion()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("*.go-mono.com");
            SecurityElement         se  = smc.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            smc.FromXml(w);
        }
예제 #9
0
        public void ToFromXmlRoundTrip()
        {
            SiteMembershipCondition smc1 = new SiteMembershipCondition("*.go-mono.com");
            SecurityElement         se   = smc1.ToXml();

            SiteMembershipCondition smc2 = new SiteMembershipCondition("*");

            smc2.FromXml(se);

            Assert.AreEqual(smc1.GetHashCode(), smc2.GetHashCode(), "ToFromXmlRoundTrip");
        }
예제 #10
0
        public void FromXml_NoClass()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("*.go-mono.com");
            SecurityElement         se  = smc.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("version", se.Attribute("version"));
            smc.FromXml(w);
            // doesn't even care of the class attribute presence
        }
        public void FromXml_PolicyLevel()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("*.example.com");
            SecurityElement         se  = smc.ToXml();
            // is it accepted for all policy levels ?
            IEnumerator e = SecurityManager.PolicyHierarchy();

            while (e.MoveNext())
            {
                PolicyLevel             pl  = e.Current as PolicyLevel;
                SiteMembershipCondition spl = new SiteMembershipCondition("*");
                spl.FromXml(se, pl);
                Assert.IsTrue(spl.Equals(smc), "FromXml(PolicyLevel='" + pl.Label + "')");
            }
            // yes!
        }
예제 #12
0
        public void Site_AllGoMonoSite()
        {
            SiteMembershipCondition smc = new SiteMembershipCondition("*.go-mono.com");

            Assert.AreEqual("*.go-mono.com", smc.Site, "Site");
            Assert.AreEqual("Site - *.go-mono.com", smc.ToString(), "ToString");

            SiteMembershipCondition smc2 = (SiteMembershipCondition)smc.Copy();

            Assert.AreEqual(smc.Site, smc2.Site, "Copy.Site");
            Assert.AreEqual(smc.GetHashCode(), smc2.GetHashCode(), "Copy.GetHashCode");

            SecurityElement         se   = smc2.ToXml();
            SiteMembershipCondition smc3 = new SiteMembershipCondition("*");

            smc3.FromXml(se);
            Assert.AreEqual(smc.Site, smc3.Site, "ToXml/FromXml");

            Assert.IsTrue(smc.Equals(smc2), "Equals");
            SiteMembershipCondition smc4 = new SiteMembershipCondition("go-mono.com");

            Assert.IsFalse(smc.Equals(smc4), "!Equals");
        }