public void ShouldReturnSubcategoriesForCategoryId()
        {
            // Arrange
            var category = new Category {
                Name = "TestCategory", Id = 1
            };
            var categoryRepository = new StubICategoryRepository
            {
                GetSubcategoriesInt32 = categoryId => new List <Subcategory>
                {
                    new Subcategory()
                    {
                        Name = "SubcategoryTest1", Id = 1, Category = category
                    },
                    new Subcategory()
                    {
                        Name = "SubcategoryTest2", Id = 2, Category = category
                    }
                }
            };
            var controller = new SubcategoriesController(categoryRepository);

            SetupControllerForTests(controller);

            // Act
            var result = controller.GetSubcategories(1);
            var returnedSubcategories = new JavaScriptSerializer().Deserialize <ICollection <Subcategory> >(result.Content.ReadAsStringAsync().Result);

            // Assert
            Assert.AreEqual(result.StatusCode, HttpStatusCode.OK);
            Assert.AreEqual(2, returnedSubcategories.Count);
        }
        public void ShouldReturnNotFoundForSubcategories()
        {
            // Arrange
            var categoryRepository = new StubICategoryRepository {
                GetSubcategoriesInt32 = categoryId => null
            };
            var controller = new SubcategoriesController(categoryRepository);

            SetupControllerForTests(controller);

            // Act
            var result = controller.GetSubcategories(1);

            // Assert
            Assert.AreEqual(result.StatusCode, HttpStatusCode.NotFound);
        }