public async Task GetGalleryCountWithNoexistingName() { ApplicationDbContext dbContext = new ApplicationDbContext(new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options); var repository = new EfDeletableEntityRepository <Pic>(dbContext); var service = new GalleryService(repository); await service.AddAsync( "http://www.test.com", "1"); Assert.Equal(0, service.GetGalleryCount("11")); dbContext.Database.EnsureDeleted(); }