public async Task AtNoPresentProductValueAddingShouldReturnFalse() { var builder = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var dbContext = new ApplicationDbContext(builder.Options); var userRepository = new EfDeletableEntityRepository <FamilyKitchenUser>(dbContext); var favoritesRepository = new EfRepository <FamilyKitchenUserFavoriteProduct>(dbContext); var productRepository = new EfDeletableEntityRepository <ShopProduct>(dbContext); var favoritesService = new FavoriteProductService(userRepository, favoritesRepository, productRepository); await userRepository.AddAsync(new FamilyKitchenUser { UserName = "******", Email = "*****@*****.**", ClientCard = new ClientCard(), ShoppingCart = new ShoppingCart(), }); await userRepository.SaveChangesAsync(); await productRepository.AddAsync(new ShopProduct { Id = 2, Name = "boza", Price = 2m, Discount = 0, }); await productRepository.SaveChangesAsync(); var actAdd = await favoritesService.Add(22, "*****@*****.**"); Assert.False(actAdd); }
public CommodityController(ModelContext context) { _context = context; commdDetailService = new CommodityDetailsService(_context); cartService = new CartService(_context); favoriteService = new FavoriteProductService(_context); }
public AccountController(ModelContext context, IHostingEnvironment hostingEnvironment) { _context = context; service1 = new SecurityService(_context); service2 = new BuyerService(_context); favoriteProductService = new FavoriteProductService(_context); followShopService = new FollowShopService(_context); receiveInformationService = new ReceiveInformationService(_context); buyerCouponService = new BuyerCouponService(_context); orderService = new OrderService(_context); _hostingEnvironment = hostingEnvironment; }