Example #1
0
        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);
            }
        }
Example #2
0
        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);
            }
        }