static void Main(string[] args) { AClass a; a = null; AClass b = new AClass(); var hashCode = b.GetHashCode(); var equal = b.Equals(null); //Default funciton generated GetHashCode //Equals, ToString(),GetType() bool ret = b == a; }
public void HashCode_ObjectsDiffOrder_AreNotEqual() { // Arrange var obj1 = new AClass("foo", 3); var obj2 = new BClass(3, "foo"); // Act var hash1 = obj1.GetHashCode(); var hash2 = obj2.GetHashCode(); // Assert Assert.NotEqual(hash1, hash2); }
public void HashCode_2ObjectsWithNulls_AreEqual() { // Arrange var obj1 = new AClass(null, 0); var obj2 = new AClass(null, 0); // Act var hash1 = obj1.GetHashCode(); var hash2 = obj2.GetHashCode(); // Assert Assert.Equal(hash1, hash2); }
public void HashCode_1ObjectWith1Not_AreNotEqual() { // Arrange var obj1 = new AClass(null, 0); var obj2 = new AClass("foo", 3); // Act var hash1 = obj1.GetHashCode(); var hash2 = obj2.GetHashCode(); // Assert Assert.NotEqual(hash1, hash2); }