public void ToXml_PolicyLevel() { UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.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! }
public void FromXml_InvalidClass() { UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com"); SecurityElement se = umc.ToXml(); se.Attributes ["class"] = "Hello world"; umc.FromXml(se); }
public void ToXml_Null() { UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com"); // no ArgumentNullException here SecurityElement se = umc.ToXml(null); Assert.IsNotNull(se, "ToXml(null)"); }
public void FromXml_InvalidTag() { UrlMembershipCondition umc = new UrlMembershipCondition("http://www.example.com"); SecurityElement se = umc.ToXml(); se.Tag = "IMonoship"; umc.FromXml(se); }
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); }
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"); }
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); }
public void FromXml_PolicyLevel() { UrlMembershipCondition umc = new UrlMembershipCondition("http://www.go-mono.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 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-*"); }
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"); }