public void Details_shows_one_album_by_id()
        {
            var albumFromService = new AlbumVm();
            catalogFacade.Setup(x => x.GetAlbumById(It.IsAny<int>())).Returns(albumFromService);

            var detailsResult = (ViewResult) storeController.Details(5);

            Assert.AreEqual(albumFromService, detailsResult.Model);
        }
 static void AssertAlbumVmMatchesAlbum(Album album, AlbumVm albumVm)
 {
     Assert.That(album.AlbumId, Is.EqualTo(albumVm.AlbumId));
     Assert.That(album.GenreId, Is.EqualTo(albumVm.GenreId));
     if (album.Genre != null) Assert.That(album.Genre.Name, Is.EqualTo(albumVm.GenreName));
     Assert.That(album.ArtistId, Is.EqualTo(albumVm.ArtistId));
     if (album.Artist != null) Assert.That(album.Artist.Name, Is.EqualTo(albumVm.ArtistName));
     Assert.That(album.Title, Is.EqualTo(albumVm.Title));
     Assert.That(album.Price, Is.EqualTo(albumVm.Price));
     Assert.That(album.AlbumArtUrl, Is.EqualTo(albumVm.AlbumArtUrl));
 }
Exemplo n.º 3
0
 GenreVm GenreToGenreVm(Genre genre)
 {
     if (genre == null) return null;
     var albumVms = new AlbumVm[] {};
     if (genre.Albums != null)
     {
         albumVms = genre.Albums.Select(AlbumToAlbumVm).ToArray();
     }
     return new GenreVm
            {
                GenreId = genre.GenreId,
                Name = genre.Name,
                Description = genre.Description,
                Albums = albumVms,
            };
 }