Exemplo n.º 1
0
        public JsonResult GetCategoryName(string id)
        {
            CategoryRepo repo = new CategoryRepo();
            string category = repo.GetCategory(id);

            return Json(category, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 2
0
        public void CanGetCategory()
        {
            CategoryRepo repo = new CategoryRepo();

            var categories = repo.GetAllCategories();

            var category1 = categories.First().CategoryName;

            var category2 = repo.GetCategory("1");

            Assert.AreEqual(category1,category2);
        }
Exemplo n.º 3
0
        public void CanAddCategory()
        {
            CategoryRepo repo = new CategoryRepo();

            var preAddCount = repo.GetAllCategories().Count;

            string category = "Unit Test";
            repo.AddCategory(category);

            var categories = repo.GetAllCategories();
            var postAddCount = categories.Count;

            Assert.AreEqual(preAddCount + 1, postAddCount);
            Assert.AreEqual(categories.Last().CategoryName, category);
        }