コード例 #1
0
 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"));
 }
コード例 #2
0
 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)));
 }
コード例 #3
0
 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)));
 }
コード例 #4
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"));
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 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);
 }