public void TwoTransientsAreNotEqual() { var personLeft = new PersonWithIntAsId(); var personRight = new PersonWithIntAsId(); personLeft.Equals(personRight).Should().BeFalse(); }
public void TransientLeftIsNotEqual() { var personLeft = new PersonWithIntAsId(); var personRight = new PersonWithIntAsId { Id = 1 }; personLeft.Equals(personRight).Should().BeFalse(); }
public void CompareTheSameReferenceReturnTrueTest() { //Arrange var entityLeft = new PersonWithIntAsId(); PersonWithIntAsId entityRight = entityLeft; //Act if (!entityLeft.Equals(entityRight)) { Assert.True(false, "entityLeft is not equal to entityRight"); } if (!(entityLeft == entityRight)) { Assert.True(false, "entityLeft is not equal to entityRight"); } }
public void SameIdentityProduceEqualsTrueTest() { var entityLeft = new PersonWithIntAsId { Id = 1 }; var entityRight = new PersonWithIntAsId { Id = 1 }; //Act bool resultOnEquals = entityLeft.Equals(entityRight); bool resultOnOperator = entityLeft == entityRight; //Assert resultOnEquals.Should().BeTrue(); resultOnOperator.Should().BeTrue(); }
public void DifferentIdProduceEqualsFalseTest() { //Arrange var entityLeft = new PersonWithIntAsId { Id = 1 }; var entityRight = new PersonWithIntAsId { Id = 2 }; //Act bool resultOnEquals = entityLeft.Equals(entityRight); bool resultOnOperator = entityLeft == entityRight; //Assert resultOnEquals.Should().BeFalse(); resultOnOperator.Should().BeFalse(); }