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 void GetAll_WhenASingleCategoryInRepository_ShouldReturnSingleCategory()
        {
            var repository = Mock.Create<IRepository<Category>>();            
            var categoryToAdd = new Category()
            {
                Name = "Test category"
            };
            IList<Category> categoryEntities = new List<Category>();
            categoryEntities.Add(categoryToAdd);
            Mock.Arrange(() => repository.All()).Returns(() => categoryEntities.AsQueryable());

            var controller = new CategoriesController(repository);

            var categoryModels = controller.GetAll();
            Assert.IsTrue(categoryModels.Count() == 1);
            Assert.AreEqual(categoryToAdd.Name, categoryModels.First().Name);
        }
        public void GetAllCategories_WhenASingleCategoryInRepository_ShouldReturnSingleCategory()
        {
            var repository = new FakeRepository<Category>();

            var categoryToAdd = new Category()
            {
                Name = "Test category"
            };
            repository.entities.Add(categoryToAdd);

            var controller = new CategoriesController(repository);

            var categoriesModels = controller.GetAll();
            Assert.IsTrue(categoriesModels.Count() == 1);
            Assert.AreEqual(categoryToAdd.Name, categoriesModels.First().Name);
        }