public void TestEquality() { // Default. var key = new AffinityKey(); Assert.IsNull(key.Key); Assert.IsNull(key.Affinity); Assert.AreEqual(0, key.GetHashCode()); Assert.AreEqual(new AffinityKey(), key); // Ctor 1. const string myKey = "myKey"; key = new AffinityKey(myKey); Assert.AreEqual(myKey, key.Key); Assert.AreEqual(myKey, key.Affinity); Assert.AreNotEqual(0, key.GetHashCode()); // Ctor 2. var ver1 = new AffinityKey(long.MaxValue, int.MaxValue); var ver2 = new AffinityKey(long.MaxValue, int.MaxValue); Assert.AreEqual(ver1, ver2); Assert.IsTrue(ver1 == ver2); Assert.IsFalse(ver1 != ver2); Assert.AreNotEqual(key, ver1); Assert.IsTrue(key != ver1); Assert.IsFalse(key == ver1); // ToString. Assert.AreEqual("AffinityKey [Key=1, Affinity=2]", new AffinityKey(1, 2).ToString()); }