public async Task RemoveAsyncShouldThrowArgumentNullForNonExistingEntity() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "RemoveAsyncShouldWork").Options; var dbContext = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <Favourite>(dbContext); var service = new FavouritesService(repository); await Assert.ThrowsAsync <ArgumentNullException>(() => service.Remove(1, "test")); }
public async Task RemoveAsyncShouldWork() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "RemoveAsyncShouldWork").Options; var dbContext = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <Favourite>(dbContext); var service = new FavouritesService(repository); await service.AddAsync(1, "test"); Assert.Single(repository.All()); await service.Remove(1, "test"); Assert.Empty(repository.All()); }