public void Equals_Should_Return_True_When_The_Compareable_Is_A_Reference() { var entity1 = new TestableEntity1() { Id = 1 }; var entity2 = entity1; Assert.True(entity1.Equals(entity2)); Assert.True(entity1.Equals((object)entity2)); Assert.True(entity1 == entity2); }
public void Comparing_To_Null_Always_Return_False() { var entity1 = new TestableEntity1() { Id = 1 }; TestableEntity1 entity2 = null; Assert.False(entity1.Equals(entity2)); Assert.False(entity1.Equals(null)); Assert.False(entity1 == entity2); Assert.False(entity1 == null); Assert.False(entity1 == (null as object)); }
public void Equals_Should_Return_False_When_Id_Is_Equal_But_Types_Are_Different() { var entity1 = new TestableEntity1() { Id = 1 }; var entity2 = new TestableEntity2() { Id = 1 }; Assert.False(entity1.Equals(entity2)); Assert.False(entity1 == entity2); }
public void Equals_Should_Return_True_When_Id_Is_Equal() { var entity1 = new TestableEntity1() { Id = 1, Name = "Number 1" }; var entity2 = new TestableEntity1() { Id = 1, Name = "Number 2" }; Assert.True(entity1.Equals(entity2)); Assert.True(entity1 == entity2); }
public void Comparing_To_Other_Entity_Should_Always_Return_False() { var entity1 = new TestableEntity1() { Id = 1 }; var entity2 = new OtherEntity() { Id = 1 }; Assert.False(entity1.Equals(entity2)); Assert.False((IBaseEntity)entity1 == (IBaseEntity)entity2); }