Exemplo n.º 1
0
        public void EntityData_CompareWithoutIdDoesNotFail()
        {
            var data1 = new MyEntity();
            var data2 = new MyEntity();

            Assert.True(data1.Equals(data2));
        }
        public void Comparison_to_null()
        {
            MyEntity entity1 = new MyEntity(1);
            MyEntity entity2 = null;
            MyEntity entity3 = null;

            (entity1 == null).Should().BeFalse();
            (entity2 == null).Should().BeTrue();
            (entity1.Equals(null)).Should().BeFalse();
            (entity2 == entity3).Should().BeTrue();
        }
        public void Entities_with_default_ids_are_not_equal()
        {
            var entity1 = new MyEntity(0);
            var entity2 = new MyEntity(0);

            bool equals1 = entity1.Equals(entity2);
            bool equals2 = entity1 == entity2;

            equals1.Should().BeFalse();
            equals2.Should().BeFalse();
        }
        public void Two_entities_of_different_ids_are_not_equal()
        {
            var entity1 = new MyEntity(1);
            var entity2 = new MyEntity(2);

            bool equals1 = entity1.Equals(entity2);
            bool equals2 = entity1 == entity2;

            equals1.Should().BeFalse();
            equals2.Should().BeFalse();
        }
        public void Two_entities_of_the_same_id_are_equal()
        {
            var entity1 = new MyEntity(1);
            var entity2 = new MyEntity(1);

            bool equals1 = entity1.Equals(entity2);
            bool equals2 = entity1 == entity2;

            equals1.Should().BeTrue();
            equals2.Should().BeTrue();
        }
        public void Derived_entities_are_not_equal()
        {
            var entity1 = new MyEntity(1);
            var entity2 = new MyDerivedEntity(1);

            bool equals1 = entity1.Equals(entity2);
            bool equals2 = entity1 == entity2;

            equals1.Should().BeFalse();
            equals2.Should().BeFalse();
        }