public void CreateNavigation_CallTheIndexAction_EnsuresTheProperViewIsReturned() { // Arrange using (var controller = new DummyNavigationController()) { controller.TemplateName = "Vertical"; // Act var view = controller.Index() as ViewResult; // Assert Assert.AreEqual("NavigationView.Vertical", view.ViewName, "The view name is not correct."); } }
public void CreateNavigation_CallTheGetViewAction_EnsuresTheViewIsCreatedProperly() { // Arrange var viewName = "Toggle"; using (var controller = new DummyNavigationController()) { NavigationModel model = new NavigationModel(); model.CssClass = "myClass"; model.LevelsToInclude = 5; // Act var view = controller.GetView(viewName, model) as PartialViewResult; var resultNavigationModel = model as NavigationModel; // Assert Assert.AreEqual(viewName, view.ViewName, "The view name is not correct."); Assert.AreEqual(model, resultNavigationModel, "The model hasn't been passed to the view correctly."); } }
public void CreateNavigation_CallTheIndexAction_EnsuresTheModelIsProperlyCreated() { // Arrange using (var controller = new DummyNavigationController()) { controller.CssClass = "myClass"; controller.LevelsToInclude = 5; controller.SelectionMode = PageSelectionMode.CurrentPageChildren; controller.ShowParentPage = true; // Act var view = controller.Index() as ViewResult; var model = view.Model; var navigationModel = model as NavigationModel; // Assert Assert.IsNotNull(navigationModel, "The model is created correctly."); Assert.AreEqual(controller.CssClass, navigationModel.CssClass, "The CssClass property is not passed correctly."); Assert.AreEqual(controller.LevelsToInclude, navigationModel.LevelsToInclude, "The LevelsToInclude property is not passed correctly."); Assert.AreEqual(controller.SelectionMode, navigationModel.SelectionMode, "The SelectionMode property is not passed correctly."); Assert.AreEqual(controller.ShowParentPage, navigationModel.ShowParentPage, "The ShowParentPage property is not passed correctly."); } }