public async Task EditSubCategory_ReturnsTrue_IfNameIsUnique() { var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var subCategoryRepository = new EfDeletableEntityRepository <SubCategory>(context); var subCategoryService = new SubCategoryService(subCategoryRepository); var subCategoryTestSeeder = new SubCategoryTestSeeder(); await subCategoryTestSeeder.SeedSubCategories(context); var subCategoryEditInputModel = new SubCategoryEditInputModel() { Id = "1", Name = "Unique", }; var shouldBetrue = await subCategoryService.EditSubCategory(subCategoryEditInputModel); Assert.True(shouldBetrue); }
public async Task EditSubCategory_ThrowsExceotion_IfMOdelIsIncorect() { var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var subCategoryRepository = new EfDeletableEntityRepository <SubCategory>(context); var subCategoryService = new SubCategoryService(subCategoryRepository); var subCategoryTestSeeder = new SubCategoryTestSeeder(); await subCategoryTestSeeder.SeedSubCategories(context); var subCategoryEditInputModel = new SubCategoryEditInputModel() { Id = "Incorrect", Name = "SubCategory2", }; await Assert.ThrowsAsync <ArgumentNullException>(async() => { await subCategoryService.EditSubCategory(subCategoryEditInputModel); }); }
//Sửa public bool EditSubCategory(SubCategoryDTO pSubCategoryDTO) { return(service.EditSubCategory(pSubCategoryDTO)); }