public void AdminController_Has_An_Add_Category_Get_Method() { var controller = new AdminController(); var result = controller.AddCategory(); Assert.IsNotNull(result); }
public void AdminController_Category_Get_Method_Has_Model_Of_Category() { var controller = new AdminController(); var result = controller.AddCategory() as ViewResult; Assert.IsInstanceOfType(result.ViewData.Model, typeof(Category)); }
public void AdminController_Has_An_Add_Category_Post_Method_Which_On_Success_Redirects_To_Categories() { var controller = new AdminController(); var result = controller.AddCategory(new Category() { Name = "Test" }) as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("Categories", result.RouteValues["action"]); }
public void AdminController_Has_A_Delete_Category_Post_Method_Which_On_Success_Redirects_To_Categories() { DatabaseHelpers.Initialize(true); InitializeStructureMap(); var repository = ObjectFactory.GetInstance<IBlogService>(); var controller = new AdminController(); controller.AddCategory(new Category() { Name = "Test" }); var category = repository.GetCategories().First(); var result = controller.DeleteCategory(category.Id) as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("Categories", result.RouteValues["action"]); }
public void AdminController_Has_A_Delete_Category_Post_Method_Which_Deletes_A_Category_With_Id() { DatabaseHelpers.Initialize(true); InitializeStructureMap(); var repository = ObjectFactory.GetInstance<IBlogService>(); var controller = new AdminController(); Assert.AreEqual(0, repository.GetCategories().Count); controller.AddCategory(new Category() { Name = "Test" }); Assert.AreEqual(1, repository.GetCategories().Count); var category = repository.GetCategories().First(); controller.DeleteCategory(category.Id); Assert.AreEqual(0, repository.GetCategories().Count); }