public async Task Delete_by_URL() { try { // Insert seed data into the database using one instance of the context using (var context = new BloggingContext(DBFixture.Setup.DbOpts)) { var repository = new BloggingRepository(context); await repository.AddAsync(new Blog { Url = "http://sample.com/foobar" }); await repository.SaveAsync(); } // Use a clean instance of the context to run the test using (var context = new BloggingContext(DBFixture.Setup.DbOpts)) { var repository = new BloggingRepository(context); var result = (await repository.FindByAsync(x => x.Url == "http://sample.com/foobar")).FirstOrDefault(); repository.Delete(result); await repository.SaveAsync(); Assert.Empty((await repository.FindByAsync(x => x.Url == "http://sample.com/foobar"))); } } catch (Exception) { throw; } }