コード例 #1
0
        public void DeleteProductAsyncShouldDeleteProductCorrectly()
        {
            var options = new DbContextOptionsBuilder <IntillegioContext>()
                          .UseInMemoryDatabase(databaseName: "Delete_Product_Db")
                          .Options;

            var dbContext = new IntillegioContext(options);

            var service = new ShopService(dbContext, null);

            var product = new Product();

            dbContext.Products.Add(product);
            dbContext.SaveChanges();

            var productId = dbContext.Products.LastOrDefault().Id;

            service.DeleteProductAsync(productId);

            Assert.True(dbContext
                        .Products
                        .Any(a => a.Id == productId) == false);
        }