public void TestCheckCascadeSoftDeleteNoSoftDeleteInfo() { //SETUP var options = SqliteInMemory.CreateOptions <CascadeSoftDelDbContext>(); using (var context = new CascadeSoftDelDbContext(options)) { context.Database.EnsureCreated(); var ceo = Employee.SeedEmployeeSoftDel(context); var config = new ConfigCascadeDeleteWithUserId(context); var service = new CascadeSoftDelService <ICascadeSoftDelete>(config); //ATTEMPT var status = service.CheckCascadeSoftDelete(context.Employees.IgnoreQueryFilters().Single(x => x.Name == "ProjectManager1")); //VERIFY status.IsValid.ShouldBeFalse(); status.Result.ShouldEqual(0); status.GetAllErrors().ShouldEqual("This entry isn't soft deleted."); } }
public void TestCheckCascadeSoftOfPreviousDeleteInfo() { //SETUP var options = SqliteInMemory.CreateOptions <CascadeSoftDelDbContext>(); using (var context = new CascadeSoftDelDbContext(options)) { context.Database.EnsureCreated(); var ceo = Employee.SeedEmployeeSoftDel(context); var config = new ConfigCascadeDeleteWithUserId(context); var service = new CascadeSoftDelService <ICascadeSoftDelete>(config); var numSoftDeleted = service.SetCascadeSoftDelete(context.Employees.Single(x => x.Name == "CTO")).Result; numSoftDeleted.ShouldEqual(7 + 6); Employee.ShowHierarchical(ceo, x => _output.WriteLine(x), false); //ATTEMPT var status = service.CheckCascadeSoftDelete(context.Employees.IgnoreQueryFilters().Single(x => x.Name == "CTO")); //VERIFY status.Result.ShouldEqual(7 + 6); status.Message.ShouldEqual("Are you sure you want to hard delete this entity and its 12 dependents"); } }