public void FindAllBrandsShouldReturnOnlyBrandsWhereIsDeletedIsFalse() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: $"FindAllBrandsShouldReturnOnlyBrandsWhereIsDeletedIsFalse_Brand_Database") .Options; var dbContext = new ApplicationDbContext(options); var mapper = this.SetUpAutoMapper(); var brandService = new BrandsService(dbContext, mapper); var brandName = Guid.NewGuid().ToString(); var brandName1 = Guid.NewGuid().ToString(); var brandName2 = Guid.NewGuid().ToString(); var model = new CreateBrandBindingModel { Name = brandName }; var model1 = new CreateBrandBindingModel { Name = brandName1 }; var model2 = new CreateBrandBindingModel { Name = brandName2 }; brandService.CreateBrand(model); brandService.CreateBrand(model1); brandService.CreateBrand(model2); brandService.RemoveBrand(model); brandService.RemoveBrand(model1); var brands = brandService.FindAllBrands(); Assert.True(brands.Count == 1); }
public void CreateBrandCategoryViewModelByCategoriesAndBrandsShouldCreateBrandCategoryViewModelByCategoriesAndBrands() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: $"CreateBrandCategoryViewModelByCategoriesAndBrandsShouldCreateBrandCategoryViewModelByCategoriesAndBrands_Brand_Database") .Options; var dbContext = new ApplicationDbContext(options); var mapper = this.SetUpAutoMapper(); var brandService = new BrandsService(dbContext, mapper); var categoriesService = new CategoriesService(dbContext, mapper); this.SeedDbWithCategories(dbContext); this.SeeDbdWithBrands(dbContext); var brands = brandService.FindAllBrands(); var categories = categoriesService.FindAllCategories(); var model = new CategoryBrandViewModel { Brands = brands, Categories = categories }; Assert.True(model.Brands.Count == 3 && model.Categories.Count == 3); }
public void FindAllBrandsShouldReturnAllBrands() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: $"FindAllBrandsShouldReturnAllBrands_Brand_Database") .Options; var dbContext = new ApplicationDbContext(options); var mapper = this.SetUpAutoMapper(); var brandService = new BrandsService(dbContext, mapper); this.SeeDbdWithBrands(dbContext); var brands = brandService.FindAllBrands(); Assert.True(brands.Count == 3); }
public void FindAllUserOrdersShouldReturnAllUserOrders() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: $"FindAllUserOrdersShouldReturnAllUserOrders_Orders_Database") .Options; var dbContext = new ApplicationDbContext(options); var mapper = this.SetUpAutoMapper(); var brandService = new BrandsService(dbContext, mapper); var categoriesService = new CategoriesService(dbContext, mapper); var usersService = new UsersService(dbContext, mapper); var productsService = new ProductsService(dbContext, mapper); var shoppingCartsService = new ShoppingCartsService(dbContext, productsService, usersService, mapper); var ordersService = new OrdersService(dbContext, shoppingCartsService, mapper); var favouritesService = new FavouritesService(dbContext, productsService, usersService, mapper); this.SeeDbdWithBrands(dbContext); this.SeedDbWithCategories(dbContext); var brands = brandService.FindAllBrands(); var categories = categoriesService.FindAllCategories(); var image = new Mock <IFormFile>(); this.SeedDbWithCountries(dbContext); this.SeedDbWithUserAndProduct(dbContext, productsService, mapper.Map <Category>(categories[0]), mapper.Map <Brand>(brands[0]), image.Object); var user = dbContext.Users.FirstOrDefault(x => x.UserName == "1"); var products = productsService.FindAllProducts(); var shoppingCarts = dbContext.ShoppingCarts; var shoppingCartss = dbContext.ShoppingCartProducts; var cart = this.SeedDbShoppingCartWithProducts(dbContext, user.UserName, products[0].Id); var model = this.CreateOrderCreateBindingModel(); var orderId = ordersService.CreateOrder(model, mapper.Map <ApplicationUserDTO>(user)); var orders = ordersService.FindAllUserOrders(mapper.Map <ApplicationUserDTO>(user)); Assert.True(orders.Count == 1); }