示例#1
0
        public void CreateANewCategoriesController()
        {
            var mockCategoriesContext = new MockCategoriesContext();
            var controller            = new CategoriesController(mockCategoriesContext);

            Assert.NotNull(controller);
        }
示例#2
0
        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"]);
        }
示例#3
0
        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();
        }
示例#4
0
        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);
        }