GetHashCode() 공개 메소드

public GetHashCode ( ) : int
리턴 int
		public void StrongNameMembershipCondition_MsKey ()
		{
			StrongNameMembershipCondition snmc = new StrongNameMembershipCondition (ms, null, null);
			Assert.AreEqual (ms, snmc.PublicKey, "PublicKey");
			Assert.IsNull (snmc.Name, "Name");
			Assert.IsNull (snmc.Version, "Version");
			Assert.AreEqual (ms.GetHashCode (), snmc.GetHashCode (), "GetHashCode ()");

			Assert.IsFalse (snmc.Check (hostEcmaCorlibVersion), "Check(hostEcmaCorlibVersion)");
			Assert.IsFalse (snmc.Check (hostEcmaVersion), "Check(hostEcmaVersion)");
			Assert.IsTrue (snmc.Check (hostMsSystemSecurityVersion), "Check(hostMsSystemSecurityVersion)");
			Assert.IsTrue (snmc.Check (hostMsVersion), "Check(hostMsVersion)");
			Common (snmc);
		}
		public void StrongNameMembershipCondition_Mscorlib ()
		{
			StrongNameMembershipCondition snmc = new StrongNameMembershipCondition (blob, name, version);
			Assert.AreEqual (blob, snmc.PublicKey, "PublicKey");
			Assert.AreEqual ("mscorlib", snmc.Name, "Name");
			Assert.AreEqual (version, snmc.Version, "Version");
			Assert.AreEqual (blob.GetHashCode (), snmc.GetHashCode (), "GetHashCode ()");
			Assert.IsTrue (snmc.ToString ().StartsWith ("StrongName - 00000000000000000400000000000000 name = mscorlib version = "), "ToString ()");

			Assert.IsTrue (snmc.Check (hostEcmaCorlibVersion), "Check(hostEcmaCorlibVersion)");
			Assert.IsFalse (snmc.Check (hostEcmaVersion), "Check(hostEcmaVersion)");
			Assert.IsFalse (snmc.Check (hostMsSystemSecurityVersion), "Check(hostMsSystemSecurityVersion)");
			Assert.IsFalse (snmc.Check (hostMsVersion), "Check(hostMsVersion)");
			Common (snmc);
		}
		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 void StrongNameMembershipCondition_NullNameVersion ()
		{
			StrongNameMembershipCondition snmc = new StrongNameMembershipCondition (blob, null, null);
			Assert.AreEqual (blob, snmc.PublicKey, "PublicKey");
			Assert.IsNull (snmc.Name, "Name");
			Assert.IsNull (snmc.Version, "Version");
			Assert.AreEqual (blob.GetHashCode (), snmc.GetHashCode (), "GetHashCode ()");
			Assert.AreEqual ("StrongName - 00000000000000000400000000000000", snmc.ToString (), "ToString ()");

			Assert.IsTrue (snmc.Check (hostEcmaCorlibVersion), "Check(hostEcmaCorlibVersion)");
			Assert.IsTrue (snmc.Check (hostEcmaVersion), "Check(hostEcmaVersion)");
			Assert.IsFalse (snmc.Check (hostMsSystemSecurityVersion), "Check(hostMsSystemSecurityVersion)");
			Assert.IsFalse (snmc.Check (hostMsVersion), "Check(hostMsVersion)");
			Common (snmc);
		}
예제 #5
0
 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)Activator.CreateInstance(typeof(PolicyLevel), true);
     snmc.FromXml(se);
     snmc.FromXml(se, pl);
     se = snmc.ToXml();
     se = snmc.ToXml(pl);
 }