public void GetCatByName(string expected, int id, bool valid)
        {
            CategoryResponse response = repo.GetById(id);

            Assert.AreEqual(valid, response.Success);
            if (valid == true)
            {
                Category actual = response.Categories.First();
                Assert.AreEqual(expected, actual.CategoryName);
            }
        }
Exemple #2
0
        public CategoryResponse GetById(int id)
        {
            var context = new PersonalBlogEntities();

            if (id == 0)
            {
                return(repo.GetById(id));
            }

            if (context.Categories.FirstOrDefault(c => c.CategoryId == id) == null)
            {
                var response = new CategoryResponse();
                response.Success = false;
                response.Message = "That category is not valid.";
                return(response);
            }

            return(repo.GetById(id));
        }