예제 #1
0
        public async Task Add_Variant_to_Product()
        {
            using (var uow = The <IUnitOfWorkManager>().Begin())
            {
                Product product = await _productRepository.FirstOrDefaultAsync(x => x.Title == "Adidas Awesome Sneaker");

                product.AddVariant("barcode_1", "43");

                await uow.CompleteAsync();
            }

            await UsingDbContextAsync <ProductDbContext>(async context =>
            {
                ProductVariant productVariant = await context.ProductVariants.FirstOrDefaultAsync(v => v.Barcode == "barcode_1");
                productVariant.ShouldNotBeNull();
                productVariant.Product.Title.ShouldBe("Adidas Awesome Sneaker");
            });
        }