private Edit ( |
||
baseballcard | ||
return | System.Web.Mvc.ActionResult |
public void TestEditPostValidBaseballCard() { BaseballCardController controller = new BaseballCardController(mockCardRepository.Object); BaseballCard baseballCard = new BaseballCard() { BaseballCardId = 1, Player = "Heman has teh Powerz", Team = "shera" }; RedirectToRouteResult result = controller.Edit(baseballCard) as RedirectToRouteResult; Assert.IsNotNull(result); BaseballCard bballCard = mockCardRepository.Object.GetAllCards()[1]; Assert.AreEqual(bballCard.Player, baseballCard.Player); }
public void TestEditGetValidBaseballCard() { BaseballCardController controller = new BaseballCardController(mockCardRepository.Object); int baseballCardId = 1; ViewResult result = controller.Edit(baseballCardId) as ViewResult; BaseballCard card = (BaseballCard)result.ViewData.Model; // Test the view model contains a list of fish Assert.IsNotNull(card, "The card does not exist"); Assert.IsTrue(card.Player == mockCards[1].Player); }
public void TestEditPostInvalidModelState() { string message = "There has been an error, please try again or contact System Administrator."; BaseballCardController controller = new BaseballCardController(mockCardRepository.Object); controller.ModelState.AddModelError("error", message); BaseballCard baseballCard = null; ViewResult result = controller.Edit(baseballCard) as ViewResult; Assert.IsNotNull(result); Assert.IsFalse(result.ViewData.ModelState.IsValid); Assert.IsTrue(result.ViewData.ModelState["error"].Errors.Count > 1); }
public void TestEditGetInvalidBaseballCard() { BaseballCardController controller = new BaseballCardController(mockCardRepository.Object); int baseballCardId = -1; HttpNotFoundResult result = controller.Edit(baseballCardId) as HttpNotFoundResult; Assert.IsNotNull(result); }