public void Shows_Edit_Post() { // Arrange Source source = GetTestSource(); var sources = GetTestSourceSet(); Show show = GetTestShow(source); var db = new Mock <IPersonalInformationManagerContext>(); db.Setup(e => e.Sources).Returns(sources); db.Setup(e => e.SetModified(It.IsAny <Show>())); db.Setup(e => e.SaveChanges()).Returns(1); ShowsController controller = new ShowsController(db.Object); // Act var result = (RedirectToRouteResult)controller.Edit(show, null); // Assert Assert.AreEqual("Index", result.RouteValues["action"]); }
public void Shows_Edit_Get() { // Arrange Source source = GetTestSource(); var sources = GetTestSourceSet(); var shows = new InMemoryDbSet <Show> { }; var db = new Mock <IPersonalInformationManagerContext>(); db.Setup(e => e.Sources).Returns(sources); db.Setup(e => e.Shows).Returns(shows); db.Setup(e => e.Shows.Find(It.IsAny <int>())).Returns(GetTestShow(source)); ShowsController controller = new ShowsController(db.Object); // Act ViewResult result = controller.Edit(1) as ViewResult; var model = result.Model as PersonalInformationManager.Models.Show; // Assert Assert.IsNotNull(result); Assert.AreEqual(SHOW_TITLE, model.Title); }