Ejemplo n.º 1
0
        public void Category_DeleteCategory_GoodInput()
        {
            //Arrange
            var controller = new CategoryController(new CategoryBLL(new CategoryRepoStub()));
            string categoryId = "2";
            var expectedCategory = new CategoryModel { CategoryId = 2, CategoryName = "test name" };

            //Act
            var viewResult = controller.DeleteCategory(categoryId) as ViewResult;
            var actualCategory = controller.ViewBag.Category;

            //Assert
            Assert.AreEqual(expectedCategory.CategoryId, actualCategory.CategoryId);
            Assert.AreEqual(expectedCategory.CategoryName, actualCategory.CategoryName);

            Assert.AreEqual("", viewResult.ViewName);
        }
Ejemplo n.º 2
0
        public void Category_DeleteCategory_BadInput()
        {
            //Arrange
            var controller = new CategoryController(new CategoryBLL(new CategoryRepoStub()));
            string categoryId = "123abc";

            //Act
            var viewResult = controller.DeleteCategory(categoryId) as ViewResult;

            //Assert
            Assert.AreEqual("Error", controller.ViewBag.Title);
            Assert.AreEqual("Invalid category id: " + categoryId, controller.ViewBag.Message);
            Assert.AreEqual("~/Views/Shared/Result.cshtml", viewResult.ViewName);
        }