Exemplo n.º 1
0
        public void Equals_SecondInstanceNull_ReturnsFalse()
        {
            // Arrange
            var entity1  = new SimpleEntityRepresentation1("test-id");
            var comparer = new EntityIdentityComparer <string>();

            // Act
            var result = comparer.Equals(entity1, null);

            // Assert
            Assert.False(result);
        }
Exemplo n.º 2
0
        public void IsSameAs_DifferentInstanceWithDifferentIdValue_ReturnsFalse()
        {
            // Arrange
            var entity1 = (IEntity <string>) new SimpleEntityRepresentation1("test-id");
            var entity2 = new SimpleEntityRepresentation1("test-id2");

            // Act
            var result = entity1.IsSameAs(entity2);

            // Assert
            Assert.False(result);
        }
Exemplo n.º 3
0
        public void Equals_DifferentInstanceTypeWithSameIdValue_ReturnsTrue()
        {
            // Arrange
            var entity1  = new SimpleEntityRepresentation1("test-id");
            var entity2  = new SimpleEntityRepresentation2("test-id");
            var comparer = new EntityIdentityComparer <string>();

            // Act
            var result = comparer.Equals(entity1, entity2);

            // Assert
            Assert.True(result);
        }
Exemplo n.º 4
0
        public void GetHashCode_DifferentInstanceTypeWithSameIdValue_ReturnsSameValue()
        {
            // Arrange
            var entity1  = new SimpleEntityRepresentation1("test-id");
            var entity2  = new SimpleEntityRepresentation2("test-id");
            var comparer = new EntityIdentityComparer <string>();

            // Act
            var result1 = comparer.GetHashCode(entity1);
            var result2 = comparer.GetHashCode(entity2);

            // Assert
            Assert.NotEqual(0, result1);
            Assert.Equal(result1, result2);
        }