public async Task DeleteAsyncWithValidId() { ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options); var service = new GalleryService(new EfDeletableEntityRepository <Pic>(dbContext)); await service.AddAsync( "http://www.test.com", "1"); var pic = await dbContext.Pics.FirstOrDefaultAsync(); await service.DeleteAsync(pic.Id); var result = await dbContext.Pics.Where(x => x.Id == pic.Id).FirstOrDefaultAsync(); Assert.True(result == null); dbContext.Database.EnsureDeleted(); }