public void FromXml_InvalidClass () { ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer); SecurityElement se = zmc.ToXml (); se.Attributes ["class"] = "Hello world"; zmc.FromXml (se); }
private ZoneMembershipCondition BasicTest(SecurityZone zone) { ZoneMembershipCondition zmc = new ZoneMembershipCondition(zone); Assert.AreEqual(zone, zmc.SecurityZone, "SecurityZone"); Assert.IsFalse(zmc.Check(null), "Check(null)"); Assert.IsFalse(zmc.Check(allEmpty), "Check(empty)"); Assert.IsFalse(zmc.Check(hostOther), "Check(hostOther)"); Assert.IsFalse(zmc.Check(assemblyOther), "Check(assemblyOther)"); ZoneMembershipCondition copy = (ZoneMembershipCondition)zmc.Copy(); Assert.IsTrue(zmc.Equals(copy), "Equals-1"); Assert.IsTrue(copy.Equals(zmc), "Equals-2"); Assert.IsFalse(Object.ReferenceEquals(zmc, copy), "!ReferenceEquals"); Assert.IsFalse(zmc.Equals(null), "Equals-3"); Assert.IsFalse(zmc.Equals(wrongEvidence), "Equals-4"); SecurityElement se = zmc.ToXml(); copy.FromXml(se); Assert.IsTrue(zmc.Equals(copy), "Equals-5"); Assert.AreEqual(se.ToString(), zmc.ToXml(null).ToString(), "Equals-6"); Assert.IsTrue(zmc.ToString().StartsWith("Zone - "), "ToString-1"); Assert.IsTrue(zmc.ToString().EndsWith(zmc.SecurityZone.ToString()), "ToString-2"); #if NET_2_0 Assert.AreEqual(zmc.SecurityZone.GetHashCode(), zmc.GetHashCode(), "GetHashCode"); #endif return(zmc); // for further tests }
public void FromXml_InvalidTag () { ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer); SecurityElement se = zmc.ToXml (); se.Tag = "IMonoship"; zmc.FromXml (se); }
public void FromXml_NoVersion () { ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer); SecurityElement se = zmc.ToXml (); SecurityElement w = new SecurityElement (se.Tag); w.AddAttribute ("class", se.Attribute ("class")); zmc.FromXml (w); }
public void FromXml_NoClass () { ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer); SecurityElement se = zmc.ToXml (); SecurityElement w = new SecurityElement (se.Tag); w.AddAttribute ("version", se.Attribute ("version")); zmc.FromXml (w); // doesn't even care of the class attribute presence }
public void FromXml_PolicyLevel () { ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer); SecurityElement se = zmc.ToXml (); // is it accepted for all policy levels ? IEnumerator e = SecurityManager.PolicyHierarchy (); while (e.MoveNext ()) { PolicyLevel pl = e.Current as PolicyLevel; ZoneMembershipCondition spl = new ZoneMembershipCondition (SecurityZone.Internet); spl.FromXml (se, pl); Assert.IsTrue (spl.Equals (zmc), "FromXml(PolicyLevel='" + pl.Label + "')"); } // yes! }
public void FromXml_Null() { ZoneMembershipCondition zmc = new ZoneMembershipCondition(SecurityZone.MyComputer); zmc.FromXml(null); }