public async void Dispose() { // Clean up and remove test product from database when all tests are done using (var context = new TestDbContextProvider().DbContext) { context.Remove(Product); await context.SaveChangesAsync(); } }
public async Task <Product> CreateMockProduct() { using (var context = new TestDbContextProvider().DbContext) { // Create a new dummy test product var product = MockProduct.Product(); // Add/Store this test porduct in database for unit-testing API endpoints with context.Product.Add(product); await context.SaveChangesAsync(); return(product); } }