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_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! }