public void AddNewAlbumValidArtistValidGenreTest() { var album = new Album { AlbumName = "Terrapin Station", Artist = new Artist { ArtistName = "Grateful Dead" }, Genre = new Genre { GenreName = "Rock" }, ReleaseYear = 1977, Tracks = new List <Track>() { new Track { Name = "Estimated Prophet", Number = 1, Length = 5 }, new Track { Name = "Dancin' in the Streets", Number = 2, Length = 3 }, new Track { Name = "Passenger", Number = 3, Length = 2 }, new Track { Name = "Samson and Delilah", Number = 4, Length = 3 }, new Track { Name = "Sunrise", Number = 5, Length = 3 }, new Track { Name = "Terrapin Station Park 1", Number = 6, Length = 16 }, } }; _artistRepository.Setup(f => f.GetArtistByName(It.IsAny <string>())).Returns(new Artist { ArtistName = "Grateful Dead" }); _genreRepository.Setup(f => f.GetGenreByName(It.IsAny <string>())).Returns(new Genre { GenreName = "Rock" }); _albumRepository.Setup(f => f.CreateAlbum(album)).Returns(1); var res = _albumService.AddNewAlbum(album); Assert.NotNull(res); Assert.AreEqual(res.Id, 1); }
public ActionResult Save(SaveAlbumViewModel saveAlbum) { var album = saveAlbum.ToAlbum(); _albumService.AddNewAlbum(album); return(Json(new { status = "OK" })); }