public void edit_movie_view() { // Arrange var controller = new MovieController(new MovieBLL(new MovieRepositoryStub())); // Act var actionResult = (ViewResult)controller.EditMovie(1); // Assert Assert.AreEqual(actionResult.ViewName, ""); }
public void edit_movie_Validation_Fail() { // Arrange var controller = new MovieController(new MovieBLL(new MovieRepositoryStub())); var inMovie = new Movie(); controller.ViewData.ModelState.AddModelError("error", "Fail"); // Act var result = (ViewResult)controller.EditMovie(1, inMovie); // Assert Assert.IsTrue(result.ViewData.ModelState.Count == 1); Assert.AreEqual(result.ViewData.ModelState["error"].Errors[0].ErrorMessage, "Fail"); Assert.AreEqual(result.ViewName, ""); }
public void edit_POST_Fail() { // Arrange var controller = new MovieController(new MovieBLL(new MovieRepositoryStub())); var inMovie = new Movie() { Id = 1, ImageAddress = "movieImageAddress.jpg", Title = "Title", Description = "Blockbaster", Price = 12, Genre = "Fantasy" }; // Act var result = (ViewResult)controller.EditMovie(0, inMovie); // Assert Assert.AreEqual(result.ViewName, ""); }
public void edit_movie_OK() { // Arrange var controller = new MovieController(new MovieBLL(new MovieRepositoryStub())); var inMovie = new Movie() { Id = 1, ImageAddress = "movieImageAddress.jpg", Title = "Title", Description = "Blockbaster", Price = 12, Genre = "Fantasy" }; // Act var result = (RedirectToRouteResult)controller.EditMovie(1, inMovie); // Assert Assert.AreEqual(result.RouteName, ""); Assert.AreEqual(result.RouteValues.Values.First(), "ListMovies"); }