public void EditAction_PassesModelValidation_RedirectsToIndexAction() { var homeController = new HomeController(_documentSession); var result = (RedirectToRouteResult)homeController.Edit(new Movie().NewValid()); Assert.That(result.RouteValues["action"], Is.EqualTo("Index")); }
public void EditAction_PassesModelValidation_RedirectsToIndexActionSettingMessage() { var movie = _documentSession.SaveNewMovieToRavenDB(new Movie().NewValid()); var homeController = new HomeController(_documentSession); homeController.Edit(movie); Assert.That(homeController.TempData["message"], Is.EqualTo(string.Format("Saved changes to Movie {0}", movie.Title))); }
public void EditAction_IdNotFound_RedirectsToIndexActionSettingMessage() { var homeController = new HomeController(_documentSession); homeController.Edit(0); Assert.That(homeController.TempData["message"], Is.EqualTo(string.Format("Movie {0} not found", 0))); }
public void EditAction_IdNotFound_RedirectsToIndexAction() { var homeController = new HomeController(_documentSession); var result = (RedirectToRouteResult)homeController.Edit(0); Assert.That(result.RouteValues["action"], Is.EqualTo("Index")); }
public void EditAction_IdFound_ViewModelIsMovie() { var movie = _documentSession.SaveNewMovieToRavenDB(new Movie().NewValid()); var homeController = new HomeController(_documentSession); var result = (ViewResult)homeController.Edit(movie.Id); Assert.IsInstanceOf<Movie>(result.Model); }
public void EditAction_IdFound_ReturnsViewByConvention() { var movie = _documentSession.SaveNewMovieToRavenDB(new Movie().NewValid()); var homeController = new HomeController(_documentSession); var result = (ViewResult)homeController.Edit(movie.Id); Assert.That(result.ViewName, Is.Empty); }
public void EditAction_FailsModelValidation_ReturnsViewByConvention() { var homeController = new HomeController(_documentSession); homeController.ModelState.AddModelError("Title", "The Title field is required."); var result = (ViewResult)homeController.Edit(new Movie().NewInvalid()); Assert.That(result.ViewName, Is.Empty); }