Exemplo n.º 1
0
        public void Category_EditCategory_InvalidInput()
        {
            //Arrange
            var controller = new CategoryController(new CategoryBLL(new CategoryRepoStub()));
            string categoryId = "-1";

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

            //Assert
            Assert.AreEqual("Error", controller.ViewBag.Title);
            Assert.AreEqual("Couldnt find a category with id: " + categoryId, controller.ViewBag.Message);
            Assert.AreEqual("~/Views/Shared/Result.cshtml", viewResult.ViewName);
        }
Exemplo n.º 2
0
        public void Category_EditCategory_GoodInput()
        {
            //Arrange
            var controller = new CategoryController(new CategoryBLL(new CategoryRepoStub()));
            string categoryId = "2";
            var expectedCategory = new CategoryModel { CategoryId = 2, CategoryName = "test" };

            //Act
            var viewResult = controller.EditCategory(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);
        }