public async Task <ActionResult <GalleryUserDto> > Get(int userId)
 {
     return(await Execute("An error occurred trying to load the users gallery.", async() =>
     {
         var result = await _galleryService.GetUsersGallery(userId);
         return Ok(result);
     }));
 }
示例#2
0
        public async Task WhenICallGalleryService_WithInvalidAlbumIds_IGetErrors()
        {
            _albumService.Setup(x => x.GetUserAlbums(It.IsAny <int>())).ReturnsAsync(MockAlbums());
            _photoService.Setup(x => x.GetAlbumPhotos(It.IsAny <int>())).ThrowsAsync(new DataValidationException("test"));
            _galleryService = new GalleryService(_albumService.Object, _photoService.Object);
            GalleryUserDto gallery = await _galleryService.GetUsersGallery(1);

            Assert.AreEqual(3, gallery.Albums.Count);
            Assert.AreEqual(3, gallery.Errors.Count);
        }
示例#3
0
        public async Task WhenICallGalleryService_WithValidUserId_IGetAlbumsWithPhotos()
        {
            _albumService.Setup(x => x.GetUserAlbums(It.IsAny <int>())).ReturnsAsync(MockAlbums());
            _photoService.Setup(x => x.GetAlbumPhotos(It.IsAny <int>())).ReturnsAsync(MockPhotos());
            _galleryService = new GalleryService(_albumService.Object, _photoService.Object);
            GalleryUserDto gallery = await _galleryService.GetUsersGallery(1);

            _albumService.Verify(x => x.GetUserAlbums(1), Times.Once);
            _photoService.Verify(x => x.GetAlbumPhotos(It.IsAny <int>()), Times.Exactly(3));
            Assert.AreEqual(1, gallery.UserId);
            Assert.AreEqual(3, gallery.Albums.Count);
            foreach (var album in gallery.Albums)
            {
                Assert.AreEqual(4, album.Photos.Count);
            }
        }