public void Test_AddArtist_AddsArtistToGenre() { //Arrange Genre testGenre = new Genre ("Hip Hop", "Grab your umbrella for a Lil Wayne", "Current"); testGenre.Save(); Artist testArtist = new Artist ("Muse", "1999", "An awesome group from UK", true); testArtist.Save(); Artist testArtist2 = new Artist ("The Beatles", "1959", "British Invasion anyone?", false); testArtist2.Save(); //Act testGenre.AddArtist(testArtist); testGenre.AddArtist(testArtist2); List <Artist> result = testGenre.GetArtists(); List <Artist> testList = new List <Artist> { }; testList.Add(testArtist); testList.Add(testArtist2); //Assert CollectionAssert.AreEqual(result, testList); }
public void GetArtists_ReturnsAllGenreArtists_ArtistList() { //Arrange Genre testGenre = new Genre ("DubStep", "Robots making music!", "Post-Modern"); testGenre.Save(); Artist testArtist1 = new Artist ("Lindsey Stirling", "2007", "Violinst with some good vibes!", true); testArtist1.Save(); Artist testArtist2 = new Artist ("The Doors", "1965", "Mix of this and that!", false); testArtist2.Save(); //Act testGenre.AddArtist(testArtist1); List <Artist> savedArtists = testGenre.GetArtists(); List <Artist> testList = new List <Artist> { testArtist1 }; //Assert CollectionAssert.AreEqual(savedArtists, testList); }
public ActionResult Create(int genreId, string artistDescription) { Dictionary <string, object> model = new Dictionary <string, object>(); Genre foundGenre = Genre.Find(genreId); Artist newArtist = new Artist(artistDescription); foundGenre.AddArtist(newArtist); List <Artist> genreArtists = foundGenre.Artists; model.Add("artists", genreArtists); model.Add("genre", foundGenre); return(View("Show", model)); }
public ActionResult CreateArtist() { Artist tempArtist = new Artist("", "", "", false); bool artistActivity = tempArtist.IsActive(Request.Form["artist-active"]); Artist newArtist = new Artist (Request.Form["artist-name"], Request.Form["artist-debut"], Request.Form["artist-bio"], artistActivity); newArtist.Save(); //must save to database for getAll method to grab it //saves all checked values into a string IEnumerable <String> checkedGenres = Request.Form["artist-genre"]; foreach (var genre in checkedGenres) { Genre thisGenre = Genre.Find(Int32.Parse(genre)); thisGenre.AddArtist(newArtist); } return(RedirectToAction("AllArtists", Artist.GetAll())); /*Because Artist.GetAll() is a list, the model that the AllArtists page now has * access to must have .Count method directly called on it (See AllArtists for reference)*/ }