コード例 #1
0
        public void FromXml_InvalidClass()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com");
            SecurityElement        se  = umc.ToXml();

            se.Attributes ["class"] = "Hello world";
            umc.FromXml(se);
        }
コード例 #2
0
        public void FromXml_InvalidTag()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com");
            SecurityElement        se  = umc.ToXml();

            se.Tag = "IMonoship";
            umc.FromXml(se);
        }
コード例 #3
0
        public void FromXml_NoVersion()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com");
            SecurityElement        se  = umc.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            umc.FromXml(w);
        }
コード例 #4
0
        public void ToFromXmlRoundTrip()
        {
            UrlMembershipCondition umc1 = new UrlMembershipCondition("http://www.example.com");
            SecurityElement        se   = umc1.ToXml();

            UrlMembershipCondition umc2 = new UrlMembershipCondition("*");

            umc2.FromXml(se);

            Assert.AreEqual(umc1.GetHashCode(), umc2.GetHashCode(), "ToFromXmlRoundTrip");
        }
コード例 #5
0
        public void FromXml_NoClass()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com");
            SecurityElement        se  = umc.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("version", se.Attribute("version"));
            umc.FromXml(w);
            // doesn't even care of the class attribute presence
        }
        public void FromXml_InvalidVersion()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.go-mono.com");
            SecurityElement        se  = umc.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            w.AddAttribute("version", "2");
            w.AddAttribute("Url", se.Attribute("Url"));
            umc.FromXml(w);
        }
コード例 #7
0
        public void FromXml_PolicyLevel()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com");
            SecurityElement        se  = umc.ToXml();
            // is it accepted for all policy levels ?
            IEnumerator e = SecurityManager.PolicyHierarchy();

            while (e.MoveNext())
            {
                PolicyLevel            pl  = e.Current as PolicyLevel;
                UrlMembershipCondition spl = new UrlMembershipCondition("*");
                spl.FromXml(se, pl);
                Assert.IsTrue(spl.Equals(umc), "FromXml(PolicyLevel='" + pl.Label + "')");
            }
            // yes!
        }
        public void ToXml_PolicyLevel()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.go-mono.com");
            SecurityElement        se  = umc.ToXml();
            string s = umc.ToXml().ToString();
            // is it accepted for all policy levels ?
            IEnumerator e = SecurityManager.PolicyHierarchy();

            while (e.MoveNext())
            {
                PolicyLevel            pl  = e.Current as PolicyLevel;
                UrlMembershipCondition spl = new UrlMembershipCondition("*");
                spl.FromXml(se, pl);
                Assert.AreEqual(s, spl.ToXml(pl).ToString(), "ToXml(PolicyLevel='" + pl.Label + "')");
            }
            // yes!
        }
コード例 #9
0
        public void Url_AllGoMonoUrl()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com/*");

            Assert.AreEqual("http://www.example.com/*", umc.Url, "Url");
            Assert.AreEqual("Url - http://www.example.com/*", umc.ToString(), "ToString");

            UrlMembershipCondition umc2 = (UrlMembershipCondition)umc.Copy();

            Assert.AreEqual(umc.Url, umc2.Url, "Copy.Url");
            Assert.AreEqual(umc.GetHashCode(), umc2.GetHashCode(), "Copy.GetHashCode");

            SecurityElement        se   = umc2.ToXml();
            UrlMembershipCondition umc3 = new UrlMembershipCondition("*");

            umc3.FromXml(se);
            Assert.AreEqual(umc.Url, umc3.Url, "ToXml/FromXml");

            Assert.IsTrue(umc.Equals(umc2), "Equals");
            UrlMembershipCondition umc4 = new UrlMembershipCondition("http://www.example.com/");

            Assert.IsTrue(umc.Equals(umc4), "Equals-*");
        }
コード例 #10
0
        public void UrlMembershipCondition_GoMonoWebUrl()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com/");

            Assert.AreEqual("http://www.example.com/", umc.Url, "Url");
            Assert.AreEqual("Url - http://www.example.com/", umc.ToString(), "ToString");

            UrlMembershipCondition umc2 = (UrlMembershipCondition)umc.Copy();

            Assert.AreEqual(umc.Url, umc2.Url, "Copy.Url");
            Assert.AreEqual(umc.GetHashCode(), umc2.GetHashCode(), "Copy.GetHashCode");

            SecurityElement        se   = umc2.ToXml();
            UrlMembershipCondition umc3 = new UrlMembershipCondition("*");

            umc3.FromXml(se);
            Assert.AreEqual(umc.Url, umc3.Url, "ToXml/FromXml");

            Assert.IsTrue(umc.Equals(umc2), "Equals");
            UrlMembershipCondition umc4 = new UrlMembershipCondition("http://www.example.com");

            // note that a last slash is added to Url - so it's equal
            Assert.IsTrue(umc.Equals(umc4), "Equals-AutoAddedLastSlash");
        }
コード例 #11
0
        public void FromXml_Null()
        {
            UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com");

            umc.FromXml(null);
        }