public ActionResult AddGameToRetailer(int retailerId) { Retailer retailer = Retailer.Find(retailerId); Game game = Game.Find(Int32.Parse(Request.Form["game-id"])); retailer.AddGame(game); return(RedirectToAction("RetailerDetails", new { id = retailerId })); }
public void Test_AddGame_AddsGameToRetailer() { Retailer testRetailer = new Retailer("GameStop", "www.GameStop.com"); testRetailer.Save(); Game testGame = new Game("Super Mario 64", "Platformer", "Nintendo 64", 1996, 98); testGame.Save(); Game testGame2 = new Game("Ocarina of Time", "RPG", "Nintendo 64", 1998, 99); testGame2.Save(); testRetailer.AddGame(testGame); testRetailer.AddGame(testGame2); List <Game> result = testRetailer.GetGames(); List <Game> testList = new List <Game> { testGame, testGame2 }; CollectionAssert.AreEqual(testList, result); }
public void Delete_DeletesRetailerAssociationsFromDatabase_RetailerList() { Game testGame = new Game("Super Mario 64", "Platformer", "Nintendo 64", 1996, 98); testGame.Save(); Retailer testRetailer = new Retailer("GameStop", "www.GameStop.com"); testRetailer.Save(); testRetailer.AddGame(testGame); testRetailer.Delete(); List <Retailer> resultGameRetailers = testGame.GetRetailers(); List <Retailer> testGameRetailers = new List <Retailer> { }; CollectionAssert.AreEqual(testGameRetailers, resultGameRetailers); }
public void GetGames_ReturnsAllRetailerGames_GameList() { Retailer testRetailer = new Retailer("GameStop", "www.GameStop.com"); testRetailer.Save(); Game testGame = new Game("Super Mario 64", "Platformer", "Nintendo 64", 1996, 98); testGame.Save(); Game testGame2 = new Game("Ocarina of Time", "RPG", "Nintendo 64", 1998, 99); testGame2.Save(); testRetailer.AddGame(testGame); List <Game> savedGames = testRetailer.GetGames(); List <Game> testList = new List <Game> { testGame }; CollectionAssert.AreEqual(testList, savedGames); }