public async Task TestSoftDeleteServiceSetSoftDddDeleteViaKeysOk() { //SETUP var options = SqliteInMemory.CreateOptions <SingleSoftDelDbContext>(); using (var context = new SingleSoftDelDbContext(options)) { context.Database.EnsureCreated(); var bookDdd = new BookDDD("Test"); context.Add(bookDdd); context.SaveChanges(); var config = new ConfigSoftDeleteDDD(context); var service = new SingleSoftDeleteServiceAsync <ISingleSoftDeletedDDD>(config); //ATTEMPT var status = await service.SetSoftDeleteViaKeysAsync <BookDDD>(bookDdd.Id); //VERIFY status.IsValid.ShouldBeTrue(status.GetAllErrors()); status.Result.ShouldEqual(1); } using (var context = new SingleSoftDelDbContext(options)) { context.BookDdds.Count().ShouldEqual(0); context.BookDdds.IgnoreQueryFilters().Count().ShouldEqual(1); } }
public void TestSoftDeleteServiceDddResetSoftDeleteOk() { //SETUP var options = SqliteInMemory.CreateOptions <SingleSoftDelDbContext>(); using (var context = new SingleSoftDelDbContext(options)) { context.Database.EnsureCreated(); context.Database.EnsureCreated(); var bookDdd = new BookDDD("Test"); context.Add(bookDdd); context.SaveChanges(); var config = new ConfigSoftDeleteDDD(context); var service = new SingleSoftDeleteService <ISingleSoftDeletedDDD>(config); service.SetSoftDelete(bookDdd); //ATTEMPT var status = service.ResetSoftDelete(bookDdd); //VERIFY status.IsValid.ShouldBeTrue(status.GetAllErrors()); status.Result.ShouldEqual(1); context.ChangeTracker.Clear(); context.BookDdds.Count().ShouldEqual(1); context.BookDdds.IgnoreQueryFilters().Count().ShouldEqual(1); } }