Esempio n. 1
0
        public void Delete_MainPhoto_ThrowsDomainException()
        {
            // Arrange
            var user = UserGenerator.GenerateUser();

            user.AddPhoto(new Photo("photo", "url", isMain: true));

            // Act, Assert
            Assert.Throws <DomainException>(() => user.DeletePhoto("photo"));
        }
Esempio n. 2
0
        public void Like_HappyPath_UserLiked()
        {
            // Arrange
            var       user         = UserGenerator.GenerateUser();
            const int userToLikeId = 1;

            // Act
            user.Like(userToLikeId);

            // Assert
            Assert.Single(user.UserLikes);
            Assert.Contains(user.UserLikes, ul => ul.TargetUserId == userToLikeId);
        }
Esempio n. 3
0
        public void Delete_HappyPath_PhotoSuccessfullyDeleted()
        {
            // Arrange
            var user = UserGenerator.GenerateUser();

            user.AddPhoto(new Photo("photo", "url", isMain: true));
            user.AddPhoto(new Photo("photo 2", "url"));

            // Act
            user.DeletePhoto("photo 2");

            // Assert
            Assert.Single(user.Photos);
        }
Esempio n. 4
0
        public void Like_ManyLikesToTheSameUser_DoNotCreateManyLikes()
        {
            // Arrange
            var       user         = UserGenerator.GenerateUser();
            const int userToLikeId = 1;

            // Act
            user.Like(userToLikeId);
            user.Like(userToLikeId);
            user.Like(userToLikeId);

            // Assert
            Assert.Single(user.UserLikes);
            Assert.Contains(user.UserLikes, ul => ul.TargetUserId == userToLikeId);
        }
Esempio n. 5
0
        public void Add_FirstPhoto_BecomesMain()
        {
            // Arrange
            var user  = UserGenerator.GenerateUser();
            var photo = new Photo("photo", "url");

            // Act
            user.AddPhoto(photo);

            // Assert
            Assert.Single(user.Photos);
            var mainPhoto = user.GetMainPhoto();

            Assert.NotNull(mainPhoto);
            Assert.Equal(photo.Name, mainPhoto.Name);
            Assert.Equal(photo.Url, mainPhoto.Url);
        }
Esempio n. 6
0
        public void Add_ManyPhotosAfterFirst_FirstIsStillMain()
        {
            // Arrange
            var user   = UserGenerator.GenerateUser();
            var photo  = new Photo("photo", "url");
            var photo2 = new Photo("photo 2", "url2");
            var photo3 = new Photo("photo 3", "url3");

            // Act
            user.AddPhoto(photo);
            user.AddPhoto(photo2);
            user.AddPhoto(photo3);

            // Assert
            Assert.Equal(3, user.Photos.Count);
            var mainPhoto = user.GetMainPhoto();

            Assert.NotNull(mainPhoto);
            Assert.Equal(photo.Name, mainPhoto.Name);
            Assert.Equal(photo.Url, mainPhoto.Url);
        }
Esempio n. 7
0
        public void SetAsMain_HappyPath_NewPhotoBecomesMain()
        {
            // Arrange
            var user = UserGenerator.GenerateUser();

            var photo = new Photo("photo", "url");

            user.AddPhoto(photo);

            var newPhoto = new Photo("photo 2", "url2");

            user.AddPhoto(newPhoto);

            // Act
            user.SetPhotoAsMain(newPhoto.Name);

            // Assert
            var mainPhoto = user.GetMainPhoto();

            Assert.NotNull(mainPhoto);
            Assert.Equal(newPhoto.Name, newPhoto.Name);
            Assert.Equal(newPhoto.Url, newPhoto.Url);
        }