public async Task TestHardDeleteViaKeysOk() { //SETUP var options = SqliteInMemory.CreateOptions <SingleSoftDelDbContext>(); using (var context = new SingleSoftDelDbContext(options)) { context.Database.EnsureCreated(); var book = context.AddBookWithReviewToDb(); var config = new ConfigSoftDeleteWithUserId(context); var service = new SingleSoftDeleteServiceAsync <ISingleSoftDelete>(config); var status = await service.SetSoftDeleteAsync(book); status.IsValid.ShouldBeTrue(status.GetAllErrors()); } using (var context = new SingleSoftDelDbContext(options)) { var config = new ConfigSoftDeleteWithUserId(context); var service = new SingleSoftDeleteServiceAsync <ISingleSoftDelete>(config); //ATTEMPT var status = await service.HardDeleteViaKeysAsync <Book>(context.Books.IgnoreQueryFilters().Single().Id); //VERIFY status.IsValid.ShouldBeTrue(status.GetAllErrors()); status.Result.ShouldEqual(1); } using (var context = new SingleSoftDelDbContext(options)) { context.Books.IgnoreQueryFilters().Count().ShouldEqual(0); } }
public async Task TestHardDeleteViaKeysNotFoundOk() { //SETUP var options = SqliteInMemory.CreateOptions <SingleSoftDelDbContext>(); using (var context = new SingleSoftDelDbContext(options)) { context.Database.EnsureCreated(); var book = context.AddBookWithReviewToDb(); var config = new ConfigSoftDeleteWithUserId(context); var service = new SingleSoftDeleteServiceAsync <ISingleSoftDelete>(config); var status1 = await service.SetSoftDeleteAsync(book); status1.IsValid.ShouldBeTrue(status1.GetAllErrors()); //ATTEMPT var status = await service.HardDeleteViaKeysAsync <Book>(234); //VERIFY status.IsValid.ShouldBeFalse(status.GetAllErrors()); status.GetAllErrors().ShouldEqual("Could not find the entry you ask for."); } }