Esempio n. 1
0
        public async Task DeleteCategoryAsyncShouldReturnFalse()
        {
            var categoryService = GetCategoryService.Return(db);

            await categoryService.CreateCategoryAsync(new CategoryCreateDtoModel
            {
                CategoryName = "TestCategory",
                ImageAddress = ""
            });

            var isDeleted = await categoryService.DeleteCategoryAsync(5);

            Assert.False(isDeleted);
        }
Esempio n. 2
0
        public async Task IsSameCategoryAsyncShouldReturnFalse()
        {
            var categoryService = GetCategoryService.Return(db);

            await categoryService.CreateCategoryAsync(new CategoryCreateDtoModel
            {
                CategoryName = "TestCategory",
                ImageAddress = ""
            });

            var ifExsits = await categoryService.IsSameCategoryAsync("TestCategory1", "");

            Assert.False(ifExsits);
        }
Esempio n. 3
0
        public async Task IfCategoryExistsShouldReturnTrue()
        {
            var categoryService = GetCategoryService.Return(db);

            await categoryService.CreateCategoryAsync(new CategoryCreateDtoModel
            {
                CategoryName = "TestCategory",
                ImageAddress = ""
            });

            var ifExsits = await categoryService.IfCategoryExists("TestCategory");

            Assert.True(ifExsits);
        }
Esempio n. 4
0
        private static async Task <PartService> ReturnPartService(SKAutoDbContext db)
        {
            var brandService       = GetBrandService.Return(db);
            var modelService       = GetModelService.Return(db, brandService);
            var categoryService    = GetCategoryService.Return(db);
            var manufactoryService = GetManufactoryService.Return(db);
            var partService        = GetPartService.Return(db, brandService,
                                                           modelService,
                                                           categoryService, manufactoryService);

            await brandService.CreateBrand(new BrandCreateDtoModel
            {
                Name         = "Audi",
                ImageAddress = "/Images/CarLogos/Audi-logo.png"
            });

            await modelService.CreateModel(new ModelCreateDtoModel
            {
                BrandName    = "Audi",
                Name         = "A6",
                StartYear    = 1994,
                EndYear      = 1998,
                ImageAddress = "/Images/AUDI/AUDI A6 1994-1998-.jpg"
            });


            await categoryService.CreateCategoryAsync(new CategoryCreateDtoModel
            {
                CategoryName = "Едрогабаритни части",
                ImageAddress = ""
            });

            await manufactoryService.CreateManufactoryAsync("Kaih");

            await partService.CreatePartAsync(new PartCreateInputDtoModel
            {
                PartName        = "Калник",
                CategoryName    = "Едрогабаритни части",
                ManufactoryName = "Kaih",
                ModelName       = "Audi A6 1994-1998",
                Price           = 10,
                Quantity        = 1
            });

            return(partService);
        }
Esempio n. 5
0
        public async Task GetAllCategoriesForModelAsyncShouldReturnOne()
        {
            var categoryService = GetCategoryService.Return(db);

            await categoryService.CreateCategoryAsync(new CategoryCreateDtoModel
            {
                CategoryName = "TestCategory",
                ImageAddress = ""
            });

            var allCategories = await categoryService.GetAllCategoriesForModelAsync();

            var expected = 1;
            var actual   = allCategories.Count;

            Assert.Equal(expected, actual);
        }
Esempio n. 6
0
        public async Task GetCategoryByNameAsyncShouldReturnIdOne()
        {
            var categoryService = GetCategoryService.Return(db);

            await categoryService.CreateCategoryAsync(new CategoryCreateDtoModel
            {
                CategoryName = "TestCategory",
                ImageAddress = ""
            });

            var currentCategory = await categoryService.GetCategoryByNameAsync("TestCategory");

            var expected = 1;
            var actual   = currentCategory.Id;

            Assert.Equal(expected, actual);
        }
Esempio n. 7
0
        public async Task GetCategoriesByNameAndYearssAsyncShouldReturnZero()
        {
            var categoryService = GetCategoryService.Return(db);

            await categoryService.CreateCategoryAsync(new CategoryCreateDtoModel
            {
                CategoryName = "TestCategory",
                ImageAddress = ""
            });

            var allCategories = await categoryService.GetCategoriesByNameAndYears("Audi A6 1994-1998");

            var expected = 0;
            var actual   = allCategories.Count;

            Assert.Equal(expected, actual);
        }