Пример #1
0
        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);
        }
Пример #2
0
        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);
            });
        }
Пример #3
0
 //Sửa
 public bool EditSubCategory(SubCategoryDTO pSubCategoryDTO)
 {
     return(service.EditSubCategory(pSubCategoryDTO));
 }