public void GetAllByPhotoId_ShouldReturnCorrectNumber()
        {
            var user     = UserCreator.Create("test");
            var album1   = AlbumCreator.Create(false, user);
            var album2   = AlbumCreator.Create(false, user);
            var album3   = AlbumCreator.Create(false, user);
            var photo    = PhotoCreator.Create(user, false, false);
            var mapping1 = PhotoAlbumCreator.Create(photo, album1);
            var mapping2 = PhotoAlbumCreator.Create(photo, album2);
            var mapping3 = PhotoAlbumCreator.Create(photo, album3);

            var albumsRepo = DeletableEntityRepositoryMock.Get <Album>(new List <Album>()
            {
                album1, album2, album3
            });
            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo
            });
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>()
            {
                mapping1, mapping2, mapping3
            });

            var service = new PhotoAlbumService(photosRepo.Object, albumsRepo.Object, photoAlbumsRepo.Object);
            var result  = service.GetAllByPhotoId <PhotoAlbumViewModel>(photo.Id);

            Assert.Equal(3, result.Count);
        }
        public void RemovPhoto_ShouldRemoveSuccessfully()
        {
            var user    = UserCreator.Create("test");
            var photo   = PhotoCreator.Create(user, false, false);
            var album   = AlbumCreator.Create(false, user);
            var mapping = PhotoAlbumCreator.Create(photo, album);
            var list    = new List <PhotoAlbum>()
            {
                mapping
            };

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(list);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(new List <Album>()
            {
                album
            });
            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo
            });

            var service = new PhotoAlbumService(photosRepo.Object, albumsRepo.Object, photoAlbumsRepo.Object);

            service.RemovePhotoAsync(album.Id, photo.Id, user.Id).Wait();

            Assert.Empty(list);
        }
        public void AddPhoto_ShouldThrowErrorWhenPhotoAlreadyInTheAlbum()
        {
            var user    = UserCreator.Create("test");
            var photo   = PhotoCreator.Create(user, false, false);
            var album   = AlbumCreator.Create(false, user);
            var mapping = PhotoAlbumCreator.Create(photo, album);
            var list    = new List <PhotoAlbum>()
            {
                mapping
            };

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(list);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(new List <Album>()
            {
                album
            });
            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo
            });

            var       service = new PhotoAlbumService(photosRepo.Object, albumsRepo.Object, photoAlbumsRepo.Object);
            Exception ex      = Assert.Throws <AggregateException>(() => service.AddPhotoAsync(album.Id, photo.Id, user.Id).Wait());

            Assert.Contains("Photo is already added to the album", ex.Message);
        }
Exemplo n.º 4
0
        public void Create_ShouldCreateSuccessfully()
        {
            var user  = UserCreator.Create("test");
            var file  = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 0, "Data", "dummy.png");
            var model = new CreatePhotoInputModel()
            {
                Title            = "Test",
                Description      = "Test",
                IsCommentAllowed = false,
                IsPrivate        = false,
                LicenseId        = "Test",
                File             = file,
            };
            var list = new List <Photo>();

            var photosRepo      = DeletableEntityRepositoryMock.Get <Photo>(list);
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>());
            var storageService  = PhotoStorageServiceMock.Get();
            var metadataService = PhotoMetadataServiceMock.Get();

            var service = new PhotoService(photosRepo.Object, storageService.Object, metadataService.Object, photoAlbumsRepo.Object);

            service.CreatePhotoAsync(user.Id, "path", model).Wait();

            Assert.Single(list);
        }
Exemplo n.º 5
0
        public void Create_ShouldNotCreateWhenExtensionIsNotCorrect()
        {
            var user  = UserCreator.Create("test");
            var file  = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 0, "Data", "dummy.txt");
            var model = new CreatePhotoInputModel()
            {
                Title            = "Test",
                Description      = "Test",
                IsCommentAllowed = false,
                IsPrivate        = false,
                LicenseId        = "Test",
                File             = file,
            };
            var list = new List <Photo>();

            var photosRepo      = DeletableEntityRepositoryMock.Get <Photo>(list);
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>());
            var storageService  = PhotoStorageServiceMock.Get();
            var metadataService = PhotoMetadataServiceMock.Get();

            var       service = new PhotoService(photosRepo.Object, storageService.Object, metadataService.Object, photoAlbumsRepo.Object);
            Exception ex      = Assert.Throws <AggregateException>(() => service.CreatePhotoAsync(user.Id, "path", model).Wait());

            Assert.Contains("Invalid image extension", ex.Message);
            Assert.Empty(list);
        }
Exemplo n.º 6
0
        public void GetAlbumPhotos_ShouldReturnAllPhotosWhenUserIsOwner()
        {
            var user         = UserCreator.Create("test");
            var publicPhoto  = PhotoCreator.Create(user, false, false);
            var privatePhoto = PhotoCreator.Create(user, true, false);
            var album        = AlbumCreator.Create(false, user);

            var listAlbums = new List <Album>()
            {
                album
            };
            var listPhotoAlbums = new List <PhotoAlbum>()
            {
                PhotoAlbumCreator.Create(publicPhoto, album),
                PhotoAlbumCreator.Create(privatePhoto, album),
            };

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(listPhotoAlbums);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(listAlbums);

            var service = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);
            var photos  = service.GetAlbumPhotos <PhotoAlbumViewModel>(album.Id, user.Id);

            Assert.Equal(2, photos.Count);
        }
Exemplo n.º 7
0
        public void Update_ShouldUpdateAlbumSucessfully()
        {
            var user  = UserCreator.Create("test");
            var album = AlbumCreator.Create(false, user);
            var list  = new List <Album>()
            {
                album,
            };

            var editAlbumModel = new EditAlbumInputModel
            {
                Id          = album.Id,
                OwnerId     = user.Id,
                Description = "Updated",
                IsPrivate   = false,
                Name        = "Updated",
            };

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>());
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(list);

            var services = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);

            services.UpdateAsync(
                album.Id,
                user.Id,
                editAlbumModel).Wait();

            var item = list.First();

            Assert.Equal(editAlbumModel.Description, item.Description);
            Assert.Equal(editAlbumModel.Name, item.Name);
        }
        public void GetAllUsedAlbums_ShouldReturnCorrectNumber()
        {
            var user    = UserCreator.Create("test");
            var album1  = AlbumCreator.Create(false, user);
            var album2  = AlbumCreator.Create(false, user);
            var album3  = AlbumCreator.Create(false, user);
            var photo   = PhotoCreator.Create(user, false, false);
            var mapping = PhotoAlbumCreator.Create(photo, album1);

            var albumsRepo = DeletableEntityRepositoryMock.Get <Album>(new List <Album>()
            {
                album1, album2, album3
            });
            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo
            });
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>()
            {
                mapping
            });

            var service = new PhotoAlbumService(photosRepo.Object, albumsRepo.Object, photoAlbumsRepo.Object);
            var result  = service.GetAllUsedAlbums <AlbumViewModel>(photo.Id, user.Id);

            Assert.Single(result);
        }
        public void GetUserFavoritePhotos_ShouldReturnFavoritePhotos()
        {
            var user    = UserCreator.Create("test");
            var visitor = UserCreator.Create("visitor");
            var photo1  = PhotoCreator.Create(user, false, false);
            var photo2  = PhotoCreator.Create(user, false, false);
            var photo3  = PhotoCreator.Create(visitor, false, false);

            var favorites = new List <PhotoFavorite>()
            {
                PhotoFavoriteCreator.Create(photo1, visitor),
                PhotoFavoriteCreator.Create(photo2, visitor),
                PhotoFavoriteCreator.Create(photo3, user),
            };

            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo1, photo2, photo3
            });
            var favoritesRepo = EfRepositoryMock.Get <PhotoFavorite>(favorites);

            var service          = new FavoritesService(favoritesRepo.Object, photosRepo.Object);
            var userFavorites    = service.GetUserFavoritePhotos <PhotoViewModel>(user.Id);
            var visitorFavorites = service.GetUserFavoritePhotos <PhotoViewModel>(visitor.Id);

            Assert.Single(userFavorites);
            Assert.Equal(2, visitorFavorites.Count);
        }
Exemplo n.º 10
0
        public void Add_ShouldThrowErrorWhenPhotoDoesNotExist()
        {
            var user         = UserCreator.Create("test");
            var photo        = PhotoCreator.Create(user, false, true);
            var photosRepo   = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>());
            var commentsRepo = EfRepositoryMock.Get <Comment>(new List <Comment>());

            var service = new CommentService(photosRepo.Object, commentsRepo.Object);

            Exception ex = Assert.Throws <AggregateException>(() => service.AddAsync(photo.Id, user.Id, "comment").Wait());

            Assert.Contains("Photo does not exists!", ex.Message);
        }
        public void Add_ShouldThrowErrorWhenTopicDoesNotExists()
        {
            var user  = UserCreator.Create("test");
            var topic = TopicCreator.Create(user);
            var list  = new List <Topic>();

            var topicRepo        = DeletableEntityRepositoryMock.Get <Topic>(new List <Topic>());
            var topicRepliesRepo = EfRepositoryMock.Get <TopicReply>(new List <TopicReply>());
            var service          = new TopicReplyService(topicRepliesRepo.Object, topicRepo.Object);

            Exception ex = Assert.Throws <AggregateException>(() => service.AddAsync(topic.Id, user.Id, string.Empty).Wait());

            Assert.Contains("Topic does not exist", ex.Message);
        }
Exemplo n.º 12
0
        public void Update_ShouldNotUpdateAlbumSuccessfully()
        {
            var list  = new List <Album>();
            var model = new EditAlbumInputModel {
                Id = "1", OwnerId = "2", Description = "test", IsPrivate = false, Name = "test"
            };
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>());
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(list);

            var       services = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);
            Exception ex       = Assert.Throws <AggregateException>(() => services.UpdateAsync("1", "2", model).Wait());

            Assert.Contains("Album does not exist!", ex.Message);
        }
        public void Toggle_ShouldThrowErrorWhenPhotoDoesNotExists()
        {
            var user      = UserCreator.Create("test");
            var photo     = PhotoCreator.Create(user, false, false);
            var favorites = new List <PhotoFavorite>();

            var photosRepo    = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>());
            var favoritesRepo = EfRepositoryMock.Get <PhotoFavorite>(favorites);

            var       service = new FavoritesService(favoritesRepo.Object, photosRepo.Object);
            Exception ex      = Assert.Throws <AggregateException>(() => service.ToggleAsync(photo.Id, user.Id).Wait());

            Assert.Contains("Photo does not exist", ex.Message);
        }
Exemplo n.º 14
0
        public void Delete_ShouldThrowExceptionWhenPhotoDoesNotExists()
        {
            var user  = UserCreator.Create("test");
            var photo = PhotoCreator.Create(user, false, false);

            var list            = new List <Photo>();
            var photosRepo      = DeletableEntityRepositoryMock.Get <Photo>(list);
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>());
            var storageService  = PhotoStorageServiceMock.Get();
            var metadataService = PhotoMetadataServiceMock.Get();

            var       service = new PhotoService(photosRepo.Object, storageService.Object, metadataService.Object, photoAlbumsRepo.Object);
            Exception ex      = Assert.Throws <AggregateException>(() => service.DeletePhotoAsync(photo.Id, user.Id).Wait());

            Assert.Contains("Such photo does not exists", ex.Message);
        }
Exemplo n.º 15
0
        public void Add_ShouldAddSucessfully()
        {
            var user       = UserCreator.Create("test");
            var photo      = PhotoCreator.Create(user, false, true);
            var comments   = new List <Comment>();
            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo
            });
            var commentsRepo = EfRepositoryMock.Get <Comment>(comments);

            var service = new CommentService(photosRepo.Object, commentsRepo.Object);

            service.AddAsync(photo.Id, user.Id, "comment").Wait();
            Assert.Single(comments);
        }
Exemplo n.º 16
0
        public void GetById_ShouldReturnNullDataWhenAlbumDoesNotExists()
        {
            var user  = UserCreator.Create("test");
            var album = AlbumCreator.Create(false, user);

            var listAlbums      = new List <Album>();
            var listPhotoAlbums = new List <PhotoAlbum>();

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(listPhotoAlbums);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(listAlbums);

            var service       = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);
            var returnedAlbum = service.GetById <AlbumViewModel>(album.Id, user.Id);

            Assert.Null(returnedAlbum);
        }
Exemplo n.º 17
0
        public void Create_ShouldCreateAlbumSuccessfully()
        {
            var list  = new List <Album>();
            var model = new CreateAlbumInputModel()
            {
                Description = "TestDesc", IsPrivate = false, Name = "testName"
            };
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>());
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(list);

            var services = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);

            services.CreateAsync(model, "testUser").Wait();

            Assert.Single(list);
        }
Exemplo n.º 18
0
        public void GetAlbumPhotos_ShouldThrowErrorWhenAlbumDoesNotExists()
        {
            var user  = UserCreator.Create("test");
            var album = AlbumCreator.Create(false, user);

            var listAlbums      = new List <Album>();
            var listPhotoAlbums = new List <PhotoAlbum>();

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(listPhotoAlbums);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(listAlbums);

            var service = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);

            Exception ex = Assert.Throws <Exception>(() => service.GetAlbumPhotos <PhotoAlbumViewModel>(album.Id, user.Id));

            Assert.Contains("Album does not exist!", ex.Message);
        }
        public void Add_ShouldExecuteCorrectly()
        {
            var user  = UserCreator.Create("test");
            var topic = TopicCreator.Create(user);
            var list  = new List <TopicReply>();

            var topicRepo = DeletableEntityRepositoryMock.Get <Topic>(new List <Topic>()
            {
                topic
            });
            var topicRepliesRepo = EfRepositoryMock.Get <TopicReply>(list);
            var service          = new TopicReplyService(topicRepliesRepo.Object, topicRepo.Object);

            service.AddAsync(topic.Id, user.Id, string.Empty).Wait();

            Assert.Single(list);
        }
Exemplo n.º 20
0
        public void Delete_ShouldNotDeleteWhenAlbumIsDoesNotExists()
        {
            var user       = UserCreator.Create("test");
            var album      = AlbumCreator.Create(false, user);
            var photo      = PhotoCreator.Create(user, false, false);
            var photoAlbum = PhotoAlbumCreator.Create(photo, album);

            var listAlbums      = new List <Album>();
            var listPhotoAlbums = new List <PhotoAlbum>();

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(listPhotoAlbums);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(listAlbums);

            var       service = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);
            Exception ex      = Assert.Throws <AggregateException>(() => service.DeleteAsync(album.Id, user.Id).Wait());

            Assert.Contains("Album does not exist!", ex.Message);
        }
        public void Toggle_ShouldNotMakeFavoriteWhenUserOwnsThePhoto()
        {
            var user      = UserCreator.Create("test");
            var photo     = PhotoCreator.Create(user, false, false);
            var favorites = new List <PhotoFavorite>();

            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo
            });
            var favoritesRepo = EfRepositoryMock.Get <PhotoFavorite>(favorites);

            var service = new FavoritesService(favoritesRepo.Object, photosRepo.Object);

            service.ToggleAsync(photo.Id, user.Id).Wait();

            Assert.Empty(favorites);
        }
Exemplo n.º 22
0
        public void GetAllByUserId_ShouldReturnAllPhotosWhenUserIsOwner()
        {
            var user         = UserCreator.Create("test");
            var privatePhoto = PhotoCreator.Create(user, true, false);
            var publicPhoto  = PhotoCreator.Create(user, false, false);

            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                privatePhoto, publicPhoto
            });
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>());
            var storageService  = PhotoStorageServiceMock.Get();
            var metadataService = PhotoMetadataServiceMock.Get();

            var service = new PhotoService(photosRepo.Object, storageService.Object, metadataService.Object, photoAlbumsRepo.Object);
            var result  = service.GetAllByUserId <PhotoViewModel>(user.Id, user.Id);

            Assert.Equal(2, result.Count);
        }
        public void AddPhoto_ShouldThrowErrorWhenAlbumDoesNotExist()
        {
            var user  = UserCreator.Create("test");
            var photo = PhotoCreator.Create(user, false, false);
            var album = AlbumCreator.Create(false, user);
            var list  = new List <PhotoAlbum>();

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(list);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(new List <Album>());
            var photosRepo      = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo
            });

            var       service = new PhotoAlbumService(photosRepo.Object, albumsRepo.Object, photoAlbumsRepo.Object);
            Exception ex      = Assert.Throws <AggregateException>(() => service.AddPhotoAsync(album.Id, photo.Id, user.Id).Wait());

            Assert.Contains("Album does not exist", ex.Message);
        }
        public void Toggle_ShouldMakeFavoriteWhenMappingDoesNotExist()
        {
            var user        = UserCreator.Create("test");
            var visitorUser = UserCreator.Create("visitor");
            var photo       = PhotoCreator.Create(user, false, false);
            var favorites   = new List <PhotoFavorite>();

            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo
            });
            var favoritesRepo = EfRepositoryMock.Get <PhotoFavorite>(favorites);

            var service = new FavoritesService(favoritesRepo.Object, photosRepo.Object);

            service.ToggleAsync(photo.Id, visitorUser.Id).Wait();

            Assert.Single(favorites);
        }
Exemplo n.º 25
0
        public void Delete_ShouldDeleteSuccessfully()
        {
            var user  = UserCreator.Create("test");
            var album = AlbumCreator.Create(false, user);

            var listAlbums = new List <Album>()
            {
                album
            };
            var listPhotoAlbums = new List <PhotoAlbum>();

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(listPhotoAlbums);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(listAlbums);

            var service = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);

            service.DeleteAsync(album.Id, user.Id).Wait();

            Assert.Empty(listAlbums);
        }
Exemplo n.º 26
0
        public void GetUserAlbums_ShouldReturnAllAlbumsWhereUserIsOwner()
        {
            var user         = UserCreator.Create("test");
            var privateAlbum = AlbumCreator.Create(true, user);
            var publicAlbum  = AlbumCreator.Create(false, user);

            var listAlbums = new List <Album>()
            {
                privateAlbum, publicAlbum
            };
            var listPhotoAlbums = new List <PhotoAlbum>();

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(listPhotoAlbums);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(listAlbums);

            var service = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);
            var albums  = service.GetUserAlbums <AlbumViewModel>(user.Id, user.Id);

            Assert.Equal(2, albums.Count);
        }
Exemplo n.º 27
0
        public void Delete_ShouldDeletePhotoSuccessfully()
        {
            var user  = UserCreator.Create("test");
            var photo = PhotoCreator.Create(user, false, false);

            var list = new List <Photo>()
            {
                photo
            };
            var photosRepo      = DeletableEntityRepositoryMock.Get <Photo>(list);
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>());
            var storageService  = PhotoStorageServiceMock.Get();
            var metadataService = PhotoMetadataServiceMock.Get();

            var service = new PhotoService(photosRepo.Object, storageService.Object, metadataService.Object, photoAlbumsRepo.Object);

            service.DeletePhotoAsync(photo.Id, user.Id).Wait();

            Assert.Empty(list);
        }
Exemplo n.º 28
0
        public void GetLatestPublic_ShouldReturnOnlyPublicPhotos()
        {
            var user   = UserCreator.Create("test");
            var photos = new List <Photo>()
            {
                PhotoCreator.Create(user, false, false),
                PhotoCreator.Create(user, true, false),
                PhotoCreator.Create(user, false, false),
                PhotoCreator.Create(user, true, false),
            };

            var photosRepo      = DeletableEntityRepositoryMock.Get <Photo>(photos);
            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(new List <PhotoAlbum>());
            var storageService  = PhotoStorageServiceMock.Get();
            var metadataService = PhotoMetadataServiceMock.Get();

            var service = new PhotoService(photosRepo.Object, storageService.Object, metadataService.Object, photoAlbumsRepo.Object);
            var result  = service.GetLatestPublic <PhotoViewModel>();

            Assert.Equal(2, result.Count);
        }
Exemplo n.º 29
0
        public void GetById_ShouldReturnCorrectData()
        {
            var user  = UserCreator.Create("test");
            var album = AlbumCreator.Create(false, user);

            var listAlbums = new List <Album>()
            {
                album
            };
            var listPhotoAlbums = new List <PhotoAlbum>();

            var photoAlbumsRepo = EfRepositoryMock.Get <PhotoAlbum>(listPhotoAlbums);
            var albumsRepo      = DeletableEntityRepositoryMock.Get <Album>(listAlbums);

            var service       = new AlbumsService(albumsRepo.Object, photoAlbumsRepo.Object);
            var returnedAlbum = service.GetById <AlbumViewModel>(album.Id, user.Id);

            Assert.Equal(album.Id, returnedAlbum.Id);
            Assert.Equal(album.Name, returnedAlbum.Name);
            Assert.Equal(album.Description, returnedAlbum.Description);
        }
        public void UserHasFavoritePhoto_ShouldFalseWhenPhotoIsNotFavoriteToTheUser()
        {
            var user        = UserCreator.Create("test");
            var visitorUser = UserCreator.Create("visitor");
            var photo       = PhotoCreator.Create(user, false, false);
            var favorites   = new List <PhotoFavorite>()
            {
                PhotoFavoriteCreator.Create(photo, visitorUser)
            };

            var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()
            {
                photo
            });
            var favoritesRepo = EfRepositoryMock.Get <PhotoFavorite>(favorites);

            var service = new FavoritesService(favoritesRepo.Object, photosRepo.Object);
            var actual  = service.UserHasFavoritePhoto(photo.Id, user.Id);

            Assert.False(actual);
        }