public async void CanDeleteBasketProduct() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("GetBasektProduct").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { InventoryService inventoryService = new InventoryService(context); BasketProductService basketProductService = new BasketProductService(context); BasketService basketService = new BasketService(context); Basket basket = new Basket(); await basketService.CreateBasketAsync(basket); Product product = new Product(); await inventoryService.CreateProduct(product); await basketProductService.AddBasketProduct(product.ID, 3, basket.ID); var basketProduct = await basketProductService.GetBasketProductByID(basket.ID, product.ID); await basketProductService.DeleteBasketProductByID(basket.ID, product.ID); var actual = await basketProductService.GetBasketProductByID(basket.ID, product.ID); Assert.Null(actual); } }
public async void CanDeleteCheckoutProduct() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("GetBasektProduct").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { InventoryService inventoryService = new InventoryService(context); CheckoutProductService checkoutProductService = new CheckoutProductService(context); CheckoutService checkoutService = new CheckoutService(context); Checkout checkout = new Checkout(); await checkoutService.CreateCheckoutAsync(checkout); Product product = new Product(); await inventoryService.CreateProduct(product); await checkoutProductService.AddCheckoutProduct(product.ID, 3, checkout.ID); var checkoutProduct = await checkoutProductService.GetCheckoutProductByID(checkout.ID, product.ID); await checkoutProductService.DeleteCheckoutProductByID(checkout.ID, product.ID); var actual = await checkoutProductService.GetCheckoutProductByID(checkout.ID, product.ID); Assert.Null(actual); } }
public async void CanCreateBasket() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("test").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { Basket basket = new Basket(); BasketService basketService = new BasketService(context); await basketService.CreateBasketAsync(basket); var expected = await context.Baskets.FirstOrDefaultAsync(b => b.ID == basket.ID); Assert.Equal(expected, basket); } }
public async void CanGetProduct() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("test").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { InventoryService inventoryService = new InventoryService(context); Product product = new Product(); await inventoryService.CreateProduct(product); var expected = await inventoryService.GetProductByID(product.ID); Assert.Equal(expected, product); } }
public async void CanCreateCheckout() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("test").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { Checkout checkout = new Checkout(); CheckoutService checkoutService = new CheckoutService(context); await checkoutService.CreateCheckoutAsync(checkout); var expected = await context.Checkouts.FirstOrDefaultAsync(b => b.ID == checkout.ID); Assert.Equal(expected, checkout); } }
public async void CanGetCheckout() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("test").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { Checkout checkout = new Checkout(); checkout.UserID = "userString"; CheckoutService checkoutService = new CheckoutService(context); await checkoutService.CreateCheckoutAsync(checkout); var expected = await checkoutService.GetCheckoutByUserId(checkout.UserID, checkout.ID); Assert.Equal(expected, checkout); } }
public async void CanGetBasket() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("test").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { Basket basket = new Basket(); basket.UserID = "userString"; BasketService basketService = new BasketService(context); await basketService.CreateBasketAsync(basket); var expected = await basketService.GetBasketByUserId("userString"); Assert.Equal(expected, basket); } }
public async void CanUpdateBasket() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("test").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { Basket basket = new Basket(); basket.UserID = "userString"; BasketService basketService = new BasketService(context); await basketService.CreateBasketAsync(basket); basket.UserID = "new string"; await basketService.UpdateBasketAsync(basket); Assert.Equal("new string", basket.UserID); } }
public async void CanUpdateCheckout() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("test").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { Checkout checkout = new Checkout(); checkout.UserID = "userString"; CheckoutService checkoutService = new CheckoutService(context); await checkoutService.CreateCheckoutAsync(checkout); checkout.UserID = "new string"; await checkoutService.UpdateCheckoutAsync(checkout); Assert.Equal("new string", checkout.UserID); } }
public async void CanGetAllProduct() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("check2").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { InventoryService inventoryService = new InventoryService(context); Product product = new Product(); await inventoryService.CreateProduct(product); var expected = await inventoryService.GetAllProducts(); Assert.Equal(new List <Product> { product }, expected); } }
public async void CanUpdateProduct() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("check3").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { InventoryService inventoryService = new InventoryService(context); Product product = new Product(); product.Name = "flower"; await inventoryService.CreateProduct(product); product.Name = "sunflower"; await inventoryService.Update(product); var expected = await inventoryService.GetProductByID(product.ID); Assert.Equal("sunflower", expected.Name); } }
public async void CanCreateCheckoutProduct() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("test").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { InventoryService inventoryService = new InventoryService(context); CheckoutProductService checkoutProductService = new CheckoutProductService(context); CheckoutService checkoutService = new CheckoutService(context); Checkout checkout = new Checkout(); await checkoutService.CreateCheckoutAsync(checkout); Product product = new Product(); await inventoryService.CreateProduct(product); await checkoutProductService.AddCheckoutProduct(product.ID, 3, checkout.ID); var expected = await context.CheckoutProducts.FirstOrDefaultAsync(p => p.CheckoutID == checkout.ID && p.ProductID == product.ID); Assert.NotNull(expected); } }
public async void CanCreateBasketProduct() { DbContextOptions <NurseryDbContext> options = new DbContextOptionsBuilder <NurseryDbContext>().UseInMemoryDatabase("test").Options; using (NurseryDbContext context = new NurseryDbContext(options)) { InventoryService inventoryService = new InventoryService(context); BasketProductService basketProductService = new BasketProductService(context); BasketService basketService = new BasketService(context); Basket basket = new Basket(); await basketService.CreateBasketAsync(basket); Product product = new Product(); await inventoryService.CreateProduct(product); await basketProductService.AddBasketProduct(product.ID, 3, basket.ID); var expected = await context.BasketProducts.FirstOrDefaultAsync(p => p.BasketID == basket.ID && p.ProductID == product.ID); Assert.NotNull(expected); } }
public ChildService(NurseryDbContext context) { _context = context; }
public NurseryDbContextSeedData(NurseryDbContext context, UserManager<ApplicationUser> userManager, RoleManager<IdentityRole> roleManager) { _context = context; _userManager = userManager; _roleManager = roleManager; }
/// <summary> /// Constructor method that connects the service to the app's databases through its matching context. /// </summary> /// <param name="context">DbContext connection to the NurseryDb</param> public BasketService(NurseryDbContext context) { _context = context; }
/// <summary> /// Constructor method that connects the service to the app's databases through its matching context. /// </summary> /// <param name="context">DbContext connection to the NurseryDb</param> public CheckoutService(NurseryDbContext context) { _context = context; }
public NurseriesRepository(NurseryDbContext context, ILogger<NurseriesRepository> logger) { _context = context; _logger = logger; }
/// <summary> /// Constructor method that connects the service to the app's databases through its matching context. /// </summary> /// <param name="context">DbContext connection to the NurseryDb</param> public InventoryService(NurseryDbContext context) { _context = context; }
/// <summary> /// Constructor method that connects the service to the app's databases through its matching context. /// </summary> /// <param name="context">DbContext connection to the NurseryDb</param> public ShopService(NurseryDbContext context) { _context = context; }
public RegisterService(NurseryDbContext context) { _context = context; }