示例#1
0
        public async Task AddQuantityAsyncShouldAddQuoantitiesToProductQuantity()
        {
            var options = new DbContextOptionsBuilder <PhotoparallelDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var dbContext = new PhotoparallelDbContext(options);

            var productService = new ProductsService(dbContext);

            var product = new Product()
            {
                Name     = "Canon M50",
                Quantity = 5,
            };

            dbContext.Add(product);
            await dbContext.SaveChangesAsync();

            var productId = product.Id;

            await productService.AddQuantityAsync(productId, 5);

            Assert.Equal(10, product.Quantity);
        }