public void 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 SingleSoftDeleteService <ISingleSoftDelete>(context, config); var status = service.SetSoftDelete(book); status.IsValid.ShouldBeTrue(status.GetAllErrors()); } using (var context = new SingleSoftDelDbContext(options)) { var config = new ConfigSoftDeleteWithUserId(context); var service = new SingleSoftDeleteService <ISingleSoftDelete>(context, config); //ATTEMPT var status = service.HardDeleteViaKeys <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 void 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 SingleSoftDeleteService <ISingleSoftDelete>(context, config); var status1 = service.SetSoftDelete(book); status1.IsValid.ShouldBeTrue(status1.GetAllErrors()); //ATTEMPT var status = service.HardDeleteViaKeys <Book>(234); //VERIFY status.IsValid.ShouldBeFalse(status.GetAllErrors()); status.GetAllErrors().ShouldEqual("Could not find the entry you ask for."); } }