コード例 #1
0
        public void NonNullInstance_ComparedWillObject_IsFalse()
        {
            EntityWithIdOfGuid entity1 = new EntityWithIdOfGuid { Id = Guid.NewGuid() };
            object entity2 = null;

            Assert.IsFalse(entity1.Equals(entity2));
        }
コード例 #2
0
        public void Compare_InstanceWithTransientID_With_InstanceWithNonTransientID_AreNotEqual()
        {
            var entity1 = new EntityWithIdOfGuid();
            var entity2 = new EntityWithIdOfGuid {Id = Guid.NewGuid()};

            Assert.IsFalse(entity1.Equals(entity2));
        }
コード例 #3
0
        public void TwoInstances_WithDifferentIds_Should_NOT_BeEqual()
        {
            var entity1 = new EntityWithIdOfGuid { Id = Guid.NewGuid() };
            var entity2 = new EntityWithIdOfGuid { Id = Guid.NewGuid() };

            Assert.IsFalse(Equals(entity1, entity2));
            Assert.IsFalse(entity2.Equals(entity1));
            Assert.AreNotEqual(entity1.GetHashCode(), entity2.GetHashCode());
        }
コード例 #4
0
        public void TwoInstances_WithSameId_ShouldBeEqual()
        {
            var id = Guid.NewGuid();
            var entity1 = new EntityWithIdOfGuid{Id = id};
            var entity2 = new EntityWithIdOfGuid {Id = id};

            Assert.IsTrue(Equals(entity1, entity2));
            Assert.IsTrue(entity2.Equals(entity1));
            Assert.AreEqual(entity1.GetHashCode(), entity2.GetHashCode());
        }