Ejemplo n.º 1
0
        public void Equals_FirstCommentsNull_False()
        {
            // Arrange
            Comment[] comments1 = null;
            Comment[] comments2 = new Comment[]
            {
                new Comment {
                    Text = "Comment"
                },
                new Comment {
                    Text = "Comment"
                },
                new Comment {
                    Text = "Comment"
                }
            };

            Photo photo1 = new Photo {
                Path = "photo name", Comments = comments1
            };
            Photo photo2 = new Photo {
                Path = "photo name", Comments = comments2
            };

            // Act
            // Assert
            Assert.IsFalse(photo1.Equals(photo2));
            Assert.AreNotEqual(photo1, photo2);
            Assert.AreNotSame(photo1, photo2);
        }
Ejemplo n.º 2
0
        public void Equals_NullValue_Exception()
        {
            // Arrange
            Photo photo1 = new Photo();
            Photo photo2 = null;

            // Act
            // Assert
            Assert.ThrowsException <System.ArgumentNullException>(() => photo1.Equals(photo2));
        }
Ejemplo n.º 3
0
        public void Equals_TheSameInstance_True()
        {
            // Arrange
            Photo photo = new Photo();

            // Act
            // Assert
            Assert.IsTrue(photo.Equals(photo));
            Assert.AreEqual(photo, photo);
            Assert.AreSame(photo, photo);
        }
Ejemplo n.º 4
0
        public void Equals_TheSameReference_True()
        {
            // Arrange
            Photo photo1 = new Photo();
            Photo photo2 = photo1;

            // Act
            // Assert
            Assert.IsTrue(photo1.Equals(photo2));
            Assert.AreEqual(photo1, photo2);
            Assert.AreSame(photo1, photo2);
        }
Ejemplo n.º 5
0
        public void Equals_DifferentType_False()
        {
            // Arrange
            Photo     photo     = new Photo();
            PhotoLike photoLike = new PhotoLike();

            // Act
            // Assert
            Assert.IsFalse(photo.Equals(photoLike));
            Assert.AreNotEqual(photo, photoLike);
            Assert.AreNotSame(photo, photoLike);
        }
Ejemplo n.º 6
0
        public void Equals_DifferentValue_False()
        {
            // Arrange
            Photo photo1 = new Photo {
                Path = "photo name 1"
            };
            Photo photo2 = new Photo {
                Path = "photo name 2"
            };

            // Act
            // Assert
            Assert.IsFalse(photo1.Equals(photo2));
            Assert.AreNotEqual(photo1, photo2);
            Assert.AreNotSame(photo1, photo2);
        }
Ejemplo n.º 7
0
        public void Equals_TheSameValue_True()
        {
            // Arrange
            Photo photo1 = new Photo {
                Path = "photo name"
            };
            Photo photo2 = new Photo {
                Path = "photo name"
            };

            // Act
            // Assert
            Assert.IsTrue(photo1.Equals(photo2));
            Assert.AreEqual(photo1, photo2);
            Assert.AreNotSame(photo1, photo2);
        }
Ejemplo n.º 8
0
        public void Equals_DifferentLikes_False()
        {
            // Arrange
            PhotoLike[] photoLikes1 = new PhotoLike[]
            {
                new PhotoLike {
                    IsLiked = true
                },
                new PhotoLike {
                    IsLiked = true
                },
                new PhotoLike {
                    IsLiked = true
                },
                new PhotoLike {
                    IsLiked = true
                }
            };
            PhotoLike[] photoLikes2 = new PhotoLike[]
            {
                new PhotoLike {
                    IsLiked = true
                },
                new PhotoLike {
                    IsLiked = false
                },
                new PhotoLike {
                    IsLiked = false
                },
                new PhotoLike {
                    IsLiked = true
                }
            };

            Photo photo1 = new Photo {
                Path = "photo name", Likes = photoLikes1
            };
            Photo photo2 = new Photo {
                Path = "photo name", Likes = photoLikes2
            };

            // Act
            // Assert
            Assert.IsFalse(photo1.Equals(photo2));
            Assert.AreNotEqual(photo1, photo2);
            Assert.AreNotSame(photo1, photo2);
        }
Ejemplo n.º 9
0
        public void Equals_DifferentUser_False()
        {
            // Arrange
            User user1 = new User {
                NickName = "User 1"
            };
            User user2 = new User {
                NickName = "User 2"
            };

            Photo photo1 = new Photo {
                Path = "photo name", User = user1
            };
            Photo photo2 = new Photo {
                Path = "photo name", User = user2
            };

            // Act
            // Assert
            Assert.IsFalse(photo1.Equals(photo2));
            Assert.AreNotEqual(photo1, photo2);
            Assert.AreNotSame(photo1, photo2);
        }
Ejemplo n.º 10
0
        public void Equals_SameUser_True()
        {
            // Arrange
            User user1 = new User {
                NickName = "User"
            };
            User user2 = new User {
                NickName = "User"
            };

            Photo photo1 = new Photo {
                Path = "photo name", User = user1
            };
            Photo photo2 = new Photo {
                Path = "photo name", User = user2
            };

            // Act
            // Assert
            Assert.IsTrue(photo1.Equals(photo2));
            Assert.AreEqual(photo1, photo2);
            Assert.AreNotSame(photo1, photo2);
        }