public async Task DeleteCategoryAsyncTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); dbContext.Categories.Add( new Category { Id = 1, Name = "Test1", }); dbContext.Categories.Add( new Category { Id = 2, Name = "Test2", }); await dbContext.SaveChangesAsync(); var repository = new EfDeletableEntityRepository <Category>(dbContext); var service = new CategoriesService(repository); await service.DeleteCategoryAsync(1); Assert.Single(service.AllCategoryNames()); }