public void Should_Get_Photos_And_Albums_From_Repo_And_Rerturn_List_Of_PhotoAlbums()
        {
            //given
            var photo = new Photo {
                Id = 1, AlbumId = 1, Title = "phototitle"
            };

            _photoAlbumRepoMock.Setup(x => x.GetPhotos()).Returns(new List <Photo> {
                photo
            });
            var album = new Album {
                Id = 1, Title = "albumtitle"
            };

            _photoAlbumRepoMock.Setup(x => x.GetAlbums()).Returns(new List <Album> {
                album
            });

            //when
            var result = _service.GetAllPhotoAlbums();

            //then
            Assert.NotNull(result);
            Assert.IsNotEmpty(result);
            Assert.AreEqual(1, result.Count);
            Assert.NotNull(result[0].Album);
            Assert.AreEqual(album, result[0].Album);
            Assert.NotNull(result[0].Photos);
            Assert.IsNotEmpty(result[0].Photos);
            Assert.AreEqual(1, result[0].Photos.Count);
            Assert.AreEqual(photo, result[0].Photos[0]);
            _photoAlbumRepoMock.Verify(x => x.GetPhotos(), Times.Once);
            _photoAlbumRepoMock.Verify(x => x.GetAlbums(), Times.Once);
        }
Beispiel #2
0
 // GET api/photoalbum
 public PhotoAlbumModel Get()
 {
     return(_photoAlbumService.GetAllPhotoAlbums());
 }
 public JsonResult GetAllPhotoAlbums()
 {
     return(new JsonResult(_photoAlbumService.GetAllPhotoAlbums()));
 }