public void EntityCompareIdFail() { // Arrange var dummy1 = new DummyEntity(1); var dummy2 = new DummyEntity(2); // Act // Assert Assert.IsFalse(dummy1.Equals(dummy2 as object)); Assert.IsTrue(dummy1.GetHashCode() != dummy2.GetHashCode()); Assert.IsFalse(dummy1.Equals(null)); }
public void Equality_NotNullEqualsNull_ReturnsFalse() { // Arrange DummyEntity entity1 = new DummyEntity(); DummyEntity entity2 = null; // Act - Assert Assert.IsFalse(entity1 == entity2); Assert.IsFalse(entity1.Equals(entity2)); }
public void Equality_SameReference_ReturnsTrue() { // Arrange var entity1 = new DummyEntity(); var entity2 = entity1; // Act - Assert Assert.IsTrue(entity1 == entity2); Assert.IsTrue(entity1.Equals(entity2)); Assert.IsTrue(entity2.Equals(entity1)); }
public void Equality_EntityEqualsDifferentType_ReturnsFalse() { // Arrange DummyEntity entity1 = new DummyEntity(); DummyEntity entity2 = new DummyChildEntity(); // Act - Assert Assert.IsFalse(entity1 == entity2); Assert.IsFalse(entity1.Equals(entity2)); Assert.IsFalse(entity2.Equals(entity1)); }
public void EntityCompareIdSuccess() { // Arrange var dummy1 = new DummyEntity(1); var dummy2 = new DummyEntity(1); // Act // Assert Assert.IsTrue(dummy1.Equals(dummy2)); Assert.IsTrue(dummy1.GetHashCode() == dummy2.GetHashCode()); }
public void Equality_NotNullAndSameTypeButGuidEmptyId_ReturnsFalse() { // Arrange var entity1 = new DummyEntity(); entity1.ChangeId(Guid.Empty); var entity2 = new DummyEntity(); // Act - Assert Assert.IsFalse(entity1 == entity2); Assert.IsFalse(entity1.Equals(entity2)); Assert.IsFalse(entity2.Equals(entity1)); }
public void Equality_NotNullAndSameTypeAndSameId_ReturnsTrue() { // Arrange var entityId = Guid.NewGuid(); var entity1 = new DummyEntity(); entity1.ChangeId(entityId); var entity2 = new DummyEntity(); entity2.ChangeId(entityId); // Act - Assert Assert.IsTrue(entity1 == entity2); Assert.IsTrue(entity1.Equals(entity2)); Assert.IsTrue(entity2.Equals(entity1)); }