public async void DeleteOptionByProductIdAndOptionIdAsync_ShouldDelete() { // Arrange //create in memory options var options = new DbContextOptionsBuilder <DataBaseContext>() .UseInMemoryDatabase(databaseName: "DeleteOptionByProductIdAndOptionIdAsync_ShouldDelete") .Options; using (var context = new DataBaseContext(options)) { await context.AddRangeAsync(optionsList); await context.SaveChangesAsync(); Assert.Equal(2, await context.ProductOption.CountAsync()); } // Act using (var context = new DataBaseContext(options)) { var repo = new OptionRepository(context); var result = await repo.DeleteOptionByProductIdAndOptionIdAsync(firstOption.ProductId, firstOption.Id); Assert.Equal(firstOption.Id, result.Id); } using (var context = new DataBaseContext(options)) { Assert.Equal(1, await context.ProductOption.CountAsync()); } }