public void GetHashCode_new_entities_differ() { MockEntity e1 = new MockEntity() { id = 0, Guid = Guid.NewGuid().ToString() }; MockEntity e2 = new MockEntity() { id = 0, Guid = Guid.NewGuid().ToString() }; IEqualityComparer <MockEntity> comparer = new DbEntitiesComparer <MockEntity>(); Assert.AreNotEqual(comparer.GetHashCode(e1), comparer.GetHashCode(e2)); }
public void GetHashCode_persisted_entities_equal() { MockEntity e1 = new MockEntity() { id = 1 }; e1.MarkPersisted(); MockEntity e2 = new MockEntity() { id = 1 }; e2.MarkPersisted(); IEqualityComparer <MockEntity> comparer = new DbEntitiesComparer <MockEntity>(); Assert.AreEqual(comparer.GetHashCode(e1), comparer.GetHashCode(e2)); }