public void Add_WhenNameIsValid_ShouldAddTheCategory()
        {
            bool isItemAdded = false;
            var repository = Mock.Create<IRepository<Category>>();

            var categoryModel = new CategoryModel()
            {
                Name = "NEW TEST NAME"
            };
            var categoryEntity = new Category()
            {
                Id = 1,
                Name = categoryModel.Name
            };
            Mock.Arrange(() => repository.Add(Arg.IsAny<Category>()))
                .DoInstead(() => isItemAdded = true)
                .Returns(categoryEntity);

            var controller = new CategoriesController(repository);
            SetupController(controller);

            controller.PostCategory(categoryModel);

            Assert.IsTrue(isItemAdded);
        }
        public HttpResponseMessage PostCategory(CategoryModel model)
        {
            var entityToAdd = new Category()
            {
                Name = model.Name
            };

            var createdEntity = this.categoriesRepository.Add(entityToAdd);


            var createdModel = new CategoryModel()
            {
                Id = createdEntity.Id,
                Name = createdEntity.Name
            };

            var response = Request.CreateResponse<CategoryModel>(HttpStatusCode.Created, createdModel);
            var resourceLink = Url.Link("DefaultApi", new { id = createdModel.Id });

            response.Headers.Location = new Uri(resourceLink);
            return response;
        }