private void Common(StrongNameMembershipCondition snmc) { Assert.IsFalse(snmc.Check(allEmpty), "Check(allEmpty)"); Assert.IsFalse(snmc.Check(hostOther), "Check(hostOther)"); Assert.IsFalse(snmc.Check(assemblyEcmaCorlibVersion), "Check(assemblyEcmaCorlibVersion)"); Assert.IsFalse(snmc.Check(assemblyEcmaVersion), "Check(assemblyEcmaVersion)"); Assert.IsFalse(snmc.Check(assemblyMsSystemSecurityVersion), "Check(assemblyMsSystemSecurityVersion)"); Assert.IsFalse(snmc.Check(assemblyMsVersion), "Check(assemblyMsVersion)"); Assert.IsFalse(snmc.Check(assemblyOther), "Check(assemblyOther)"); StrongNameMembershipCondition copy = (StrongNameMembershipCondition)snmc.Copy(); Assert.IsTrue(copy.Equals(snmc), "copy.Equals (snmc)"); Assert.IsTrue(snmc.Equals(copy), "snmc.Equals (copy)"); copy.Name = null; copy.Version = null; bool original = ((snmc.Name == null) && (snmc.Version == null)); Assert.AreEqual(original, copy.Equals(snmc), "bad.Equals (snmc)"); Assert.AreEqual(original, snmc.Equals(copy), "snmc.Equals (bad)"); SecurityElement se = snmc.ToXml(); copy.FromXml(se); Assert.AreEqual(snmc.PublicKey, copy.PublicKey, "PublicKey"); Assert.AreEqual(snmc.Name, copy.Name, "Name"); Assert.AreEqual(snmc.Version, copy.Version, "Version"); Assert.AreEqual(snmc.GetHashCode(), copy.GetHashCode(), "GetHashCode ()"); Assert.AreEqual(snmc.ToString(), copy.ToString(), "ToString ()"); Assert.IsTrue(copy.Equals(snmc), "xml.Equals (snmc)"); Assert.IsTrue(snmc.Equals(copy), "snmc.Equals (xml)"); }
public static void StrongNameMembershipConditionCallMethods() { StrongNameMembershipCondition snmc = new StrongNameMembershipCondition(new StrongNamePublicKeyBlob(new byte[1]), "test", new Version(0, 1)); bool check = snmc.Check(new Evidence()); IMembershipCondition obj = snmc.Copy(); check = snmc.Equals(new object()); int hash = snmc.GetHashCode(); string str = snmc.ToString(); SecurityElement se = new SecurityElement(""); PolicyLevel pl = (PolicyLevel)FormatterServices.GetUninitializedObject(typeof(PolicyLevel)); snmc.FromXml(se); snmc.FromXml(se, pl); se = snmc.ToXml(); se = snmc.ToXml(pl); }