public void PostRequest_CreateCategoryTest_SuccessfulCreation() { FakeRepository<Category> categoryFakeRepository = new FakeRepository<Category>(); FakeRepository<User> userFakeRepository = new FakeRepository<User>(); FakeRepository<Thread> threadFakeRepository = new FakeRepository<Thread>(); string sessionKey = "01234567890123456789012345678901234567890123456789"; CategoryModel categoryModel = new CategoryModel() { Name = "Test category" }; User user = new User() { SessionKey = sessionKey }; userFakeRepository.Add(user); CategoriesController categoriesController = new CategoriesController( categoryFakeRepository, userFakeRepository, threadFakeRepository); SetupController(categoriesController); var response = categoriesController.CreateCategory(categoryModel, sessionKey); int expectedCategoryCount = 1; Assert.AreEqual(response.StatusCode, HttpStatusCode.Created); Assert.AreEqual(expectedCategoryCount, categoryFakeRepository.entities.Count); }
public void PostRequest_CreateCategoryTest_InvalidCreation_CannotAddNullCategory() { FakeRepository<Category> categoryFakeRepository = new FakeRepository<Category>(); FakeRepository<User> userFakeRepository = new FakeRepository<User>(); FakeRepository<Thread> threadFakeRepository = new FakeRepository<Thread>(); string sessionKey = "01234567890123456789012345678901234567890123456789"; User user = new User() { SessionKey = sessionKey }; userFakeRepository.Add(user); CategoryModel categoryModel = null; CategoriesController categoriesController = new CategoriesController( categoryFakeRepository, userFakeRepository, threadFakeRepository); SetupController(categoriesController); categoriesController.CreateCategory(categoryModel, sessionKey); }