Esempio n. 1
0
        public void DeleteCategory_ValidId_RemoveTheCategory()
        {
            var service  = new CategoryRepository(northwindDbContext);
            var category = service.AddByNameAndDescription("Test", "DeleteCategory_ValidId_RemoveTheCategory");
            var result   = service.DeleteCategory(category.Id);

            Assert.True(result);
            category = service.GetById(category.Id);
            Assert.Null(category);
        }
Esempio n. 2
0
        public void CreateCategory_ValidData_CreteCategoryAndRetunsNewObject()
        {
            var service  = new CategoryRepository(northwindDbContext);
            var category = service.AddByNameAndDescription("Test", "CreateCategory_ValidData_CreteCategoryAndRetunsNewObject");

            Assert.True(category.Id > 0);
            Assert.Equal("Test", category.Name);
            Assert.Equal("CreateCategory_ValidData_CreteCategoryAndRetunsNewObject", category.Description);

            // cleanup
            service.DeleteCategory(category.Id);
        }
Esempio n. 3
0
        public void UpdateCategory_NewNameAndDescription_UpdateWithNewValues()
        {
            var service  = new CategoryRepository(northwindDbContext);
            var category = service.AddByNameAndDescription("TestingUpdate", "UpdateCategory_NewNameAndDescription_UpdateWithNewValues");

            var result = service.UpdateCategory(category.Id, "UpdatedName", "UpdatedDescription");

            Assert.True(result);

            category = service.GetById(category.Id);

            Assert.Equal("UpdatedName", category.Name);
            Assert.Equal("UpdatedDescription", category.Description);

            // cleanup
            service.DeleteCategory(category.Id);
        }