public void CompareTheSameReferenceReturnTrueTest() { //Arrange var entityLeft = new SampleEntity(); SampleEntity entityRight = entityLeft; //Act if (! entityLeft.Equals(entityRight)) Assert.Fail(); if (!(entityLeft == entityRight)) Assert.Fail(); }
public void DiferentIdProduceEqualsFalseTest() { //Arrange var entityLeft = new SampleEntity(); var entityRight = new SampleEntity(); entityLeft.GenerateNewIdentity(); entityRight.GenerateNewIdentity(); //Act bool resultOnEquals = entityLeft.Equals(entityRight); bool resultOnOperator = entityLeft == entityRight; //Assert Assert.IsFalse(resultOnEquals); Assert.IsFalse(resultOnOperator); }
public void SameIdentityProduceEqualsTrueTest() { //Arrange Guid id = Guid.NewGuid(); var entityLeft = new SampleEntity(); var entityRight = new SampleEntity(); entityLeft.ChangeCurrentIdentity(id); entityRight.ChangeCurrentIdentity(id); //Act bool resultOnEquals = entityLeft.Equals(entityRight); bool resultOnOperator = entityLeft == entityRight; //Assert Assert.IsTrue(resultOnEquals); Assert.IsTrue(resultOnOperator); }