public void TwoEntityObjectsWithSameTypeAndVersionButDifferentIdAreDifferent() { MyEntityObject o1 = new MyEntityObject(1, 1, "Mikkel1"); MyEntityObject o2 = new MyEntityObject(2, 1, "Mikkel2"); Assert.AreNotSame(o1, o2); Assert.AreEqual(o1, o1); Assert.AreNotEqual(o1, o2); Assert.AreNotEqual(o2, o1); Assert.AreNotEqual(o1.GetHashCode(), o2.GetHashCode()); Assert.AreNotEqual(o2.GetHashCode(), o1.GetHashCode()); }
public void TwoEntityObjectsWithSameTypeSameIdAndSameVersionAreEqual() { MyEntityObject o1 = new MyEntityObject(1, 1, "Mikkel1"); MyEntityObject o2 = new MyEntityObject(1, 1, "Mikkel2"); Assert.AreNotSame(o1, o2); Assert.AreEqual(o1, o1); Assert.AreEqual(o1, o2); Assert.AreEqual(o2, o1); Assert.AreEqual(o1.GetHashCode(), o2.GetHashCode()); Assert.AreEqual(o2.GetHashCode(), o1.GetHashCode()); }
public void TwoEntityObjectsWithSameIdAndVersionButDifferentTypesAreDifferent() { MyEntityObject o1 = new MyEntityObject(1, 1, "Mikkel"); MyOtherEntityObject o2 = new MyOtherEntityObject(1, 1); MyExtendedEntityObject o3 = new MyExtendedEntityObject(1, 1, "Mikkel", 36); Assert.AreNotSame(o1, o2); Assert.AreNotSame(o1, o3); Assert.AreEqual(o1, o1); Assert.AreNotEqual(o1, o2); Assert.AreNotEqual(o2, o1); Assert.AreNotEqual(o1, o3); Assert.AreNotEqual(o3, o1); Assert.AreNotEqual(o1.GetHashCode(), o2.GetHashCode()); Assert.AreNotEqual(o2.GetHashCode(), o1.GetHashCode()); Assert.AreNotEqual(o1.GetHashCode(), o3.GetHashCode()); Assert.AreNotEqual(o3.GetHashCode(), o1.GetHashCode()); }