예제 #1
0
        public void NewPersonWithIntAsIdIsTransient()
        {
            var person = new PersonWithIntAsId();

            Assert.True(person.IsTransient());
            //person.IsTransient().Should().BeTrue();
        }
예제 #2
0
        public void CompareUsingEqualsOperatorsAndNullOperandsTest()
        {
            //Arrange

            PersonWithIntAsId entityLeft  = null;
            PersonWithIntAsId entityRight = new PersonWithIntAsId {
                Id = 2
            };

            //Act
            if (!(entityLeft == null))
            {
                Assert.True(false, "entityLeft is not null");
            }

            if (!(entityRight != null))
            {
                Assert.True(false, "entityRight is null");
            }

            entityRight = null;

            //Act
            if (!(entityLeft == entityRight))
            {
                Assert.True(false, "entityLeft is not equal to entityRight");
            }

            if (entityLeft != entityRight)
            {
                Assert.True(false, "entityLeft is not equal to entityRight");
            }
        }
        public void TwoTransientsAreNotEqual()
        {
            var personLeft  = new PersonWithIntAsId();
            var personRight = new PersonWithIntAsId();

            personLeft.Equals(personRight).Should().BeFalse();
        }
        public void CompareUsingEqualsOperatorsAndNullOperandsTest()
        {
            //Arrange

            PersonWithIntAsId entityLeft  = null;
            PersonWithIntAsId entityRight = new PersonWithIntAsId {
                Id = 2
            };

            //Act
            if (!(entityLeft == (PersonWithIntAsId)null))
            {
                Assert.Fail();
            }

            if (!(entityRight != (PersonWithIntAsId)null))
            {
                Assert.Fail();
            }

            entityRight = null;

            //Act
            if (!(entityLeft == entityRight))
            {
                Assert.Fail();
            }

            if (entityLeft != entityRight)
            {
                Assert.Fail();
            }
        }
        public void PersonWithIntAsIdWithValueIsNotTransient()
        {
            var person = new PersonWithIntAsId {
                Id = 4
            };

            person.IsTransient().Should().BeFalse();
        }
        public void TransientLeftIsNotEqual()
        {
            var personLeft  = new PersonWithIntAsId();
            var personRight = new PersonWithIntAsId {
                Id = 1
            };

            personLeft.Equals(personRight).Should().BeFalse();
        }
예제 #7
0
        public void SetIdentitySetANonTransientEntity()
        {
            //Arrange
            var entity = new PersonWithIntAsId {
                Id = 1
            };

            //Assert
            Assert.False(entity.IsTransient());
        }
예제 #8
0
        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();
        }
예제 #11
0
        public void CompareWhenLeftIsNullAndRightIsNullReturnFalseTest()
        {
            //Arrange
            PersonWithIntAsId entityLeft = null;
            var entityRight = new PersonWithIntAsId {
                Id = 1
            };

            //Act
            if (!(entityLeft == null))               //this perform ==(left,right)
            {
                Assert.True(false, "entityLeft is not null");
            }

            if (!(entityRight != null))               //this perform !=(left,right)
            {
                Assert.True(false, "entityRight is null");
            }
        }
예제 #12
0
        public void NewPersonWithIntAsIdIsTransient()
        {
            var person = new PersonWithIntAsId();

            person.IsTransient().Should().BeTrue();
        }