public async Task WhenDeleteUser_ThenUserRemovedFromDatabase() { // Arrange var productId = 1; var existingProduct = new Product(productId, "test product", 123); await _dbContext.AddAsync(existingProduct); await _dbContext.SaveChangesAsync(); // Act await _productRepository.DeleteProduct(existingProduct); // Assert (await _dbContext.Products.CountAsync()).Should().Be(0); }
public async Task <Product> CreateProduct(Product product) { await _dbContext.AddAsync(product); await _dbContext.SaveChangesAsync(); _logger.LogInformation($"Created new {nameof(Product)} with ID {product.Id}."); return(product); }