public void CreateANewCategoriesController() { var mockCategoriesContext = new MockCategoriesContext(); var controller = new CategoriesController(mockCategoriesContext); Assert.NotNull(controller); }
public void AddRedirectsToTheCategoryIndexView() { var mockCategoriesContext = new MockCategoriesContext(); var controller = new CategoriesController(mockCategoriesContext); var result = controller.Add(); Assert.IsType <RedirectToRouteResult>(result); Assert.Equal("Index", result.RouteValues["action"]); Assert.Equal("Category", result.RouteValues["controller"]); }
public void IndexRendersCategories() { var categoriesViewModel = new CategoriesViewModel(); var mockCategoriesContext = new MockCategoriesContext().StubBuildViewModelToReturn(categoriesViewModel); var controller = new CategoriesController(mockCategoriesContext); var result = (ViewResult)controller.Index(); Assert.Equal(categoriesViewModel, result.ViewData.Model); mockCategoriesContext.VerifyBuildViewModelCalled(); }
public void RemoveRedirectsToTheIndexView() { var mockCategoriesContext = new MockCategoriesContext(); var controller = new CategoriesController(mockCategoriesContext); var result = controller.Remove(10); Assert.IsType <RedirectToRouteResult>(result); Assert.Equal("Index", result.RouteValues["action"]); Assert.Equal("Categories", result.RouteValues["controller"]); mockCategoriesContext.VerifyRemoveCalledWith(10); }