 @testable import CoreDataPlus
 
 final class NSFetchRequestResultCoreDataTests: CoreDataPlusTestCase {
-
+  
   func testFetchObjectsIDs() throws {
     let context = container.viewContext
-
+    
     // Given
     context.fillWithSampleData()
     try context.save()
     XCTAssertFalse(context.registeredObjects.isEmpty)
     context.reset()
     XCTAssertTrue(context.registeredObjects.isEmpty)
-
+    
     // When
     let predicate = NSPredicate(format: "%K == %@", #keyPath(Car.maker), "McLaren")
     let ids = try Car.fetchObjectIDs(in: context, where: predicate)
-
-    // Then
-    XCTAssertEqual(ids.count, 2)
-    XCTAssertTrue(context.registeredObjects.isEmpty)
-
-    // Give, When
-    context.reset()
     let idCar = try Car.fetchObjectIDs(in: context, includingSubentities: false, where: predicate)
     let idSportCar = try SportCar.fetchObjectIDs(in: context, includingSubentities: false, where: predicate)
     let idExpensiveSportCar = try ExpensiveSportCar.fetchObjectIDs(in: context, includingSubentities: false, where: predicate)
-
+    let noIds = try Car.fetchObjectIDs(in: context, where: NSPredicate(format: "%K == %@", #keyPath(SportCar.numberPlate), "not-existing-number-plage"))
+    
     // Then
+    XCTAssertEqual(ids.count, 2)
     XCTAssertEqual(idCar.count, 0)
     XCTAssertEqual(idSportCar.count, 1)
     XCTAssertEqual(idExpensiveSportCar.count, 1)
+    XCTAssertEqual(noIds.count, 0)
     XCTAssertTrue(context.registeredObjects.isEmpty)
   }
-
+  
   func testDeleteAllIncludingSubentities() {
     let context = container.viewContext
-
+    
     // Given
     context.fillWithSampleData()
     // When

    let carsAfterDelete = try Car.fetch(in: context)
    XCTAssertTrue(carsAfterDelete.count == 3)
  }

}

    // Then
    XCTAssertFalse(try SportCar.fetch(in: context).filter { $0.numberPlate == "302" }.isEmpty)
    XCTAssertFalse(try ExpensiveSportCar.fetch(in: context).filter { $0.numberPlate == "302" }.isEmpty)
    
    // When
    XCTAssertNoThrow(try ExpensiveSportCar.deleteAll(in: context, includingSubentities: false, where: NSPredicate(format: "%K == %@", #keyPath(SportCar.numberPlate), "301")))
    // Then
    XCTAssertTrue(try SportCar.fetch(in: context).filter { $0.numberPlate == "301" }.isEmpty)
    XCTAssertTrue(try ExpensiveSportCar.fetch(in: context).filter { $0.numberPlate == "301" }.isEmpty)
    
    // When
    XCTAssertNoThrow(try SportCar.deleteAll(in: context, includingSubentities: false, where: NSPredicate(value: true)))
    // Then
    XCTAssertFalse(try SportCar.fetch(in: context).isEmpty)
    XCTAssertFalse(try ExpensiveSportCar.fetch(in: context).isEmpty)
    
    // When
    XCTAssertNoThrow(try Car.deleteAll(in: context))
    // Then
    XCTAssertTrue(try Car.fetch(in: context).isEmpty)
    
  }
  
  func testDeleteAllExcludingExceptions() throws {
    let context = container.viewContext
    context.fillWithSampleData()
    
    // Given
    let optonalCar = try Car.fetch(in: context).filter { $0.numberPlate == "5" }.first
    let optionalPerson = try Person.fetch(in: context).filter { $0.firstName == "Theodora" && $0.lastName == "Stone" }.first
    let persons = try Person.fetch(in: context).filter { $0.lastName == "Moreton" }
    
    // When
    guard let car = optonalCar, let person = optionalPerson, !persons.isEmpty else {
      XCTAssertNotNil(optonalCar)
