Пример #1
0
        public void Should_Compare_Two_Entities_Without_Id_HashCodes()
        {
            var model1 = new TestEquatableEntity();
            var model2 = new TestEquatableEntity();

            Assert.AreNotEqual(model1.GetHashCode(), model2.GetHashCode());
        }
Пример #2
0
        public void Should_Compare_Empty_Entities_Using_NotEqual_Operator()
        {
            var model1 = new TestEquatableEntity();
            var model2 = new TestEquatableEntity();
            var model3 = model1;

            Assert.IsFalse(model1 != model3);
            Assert.IsTrue(model1 != model2);
        }
Пример #3
0
        public void Should_Compare_Two_Entities_With_Same_Id_HashCodes()
        {
            var guid   = Guid.NewGuid();
            var model1 = new TestEquatableEntity {
                Id = guid
            };
            var model2 = new TestEquatableEntity {
                Id = guid
            };

            Assert.AreEqual(model1.GetHashCode(), model2.GetHashCode());
        }
Пример #4
0
        public void Should_Compare_Entities_Using_Equal_Operator()
        {
            var model1 = new TestEquatableEntity {
                Id = Guid.NewGuid()
            };
            var model2 = new TestEquatableEntity {
                Id = Guid.NewGuid()
            };
            var model3 = model1;

            Assert.IsTrue(model1 == model3);
            Assert.IsFalse(model1 == model2);
        }
Пример #5
0
        public void Should_Compare_Two_Entities_With_Same_Id()
        {
            var guid   = Guid.NewGuid();
            var model1 = new TestEquatableEntity {
                Id = guid
            };
            var model2 = new TestEquatableEntity {
                Id = guid
            };

            Assert.AreEqual(model1, model2);
            Assert.IsTrue(model1 == model2);
            Assert.IsTrue(model1.Equals(model2));
            Assert.IsTrue(model2.Equals(model1));
        }