       XCTAssertEqual(car.model, "test")
       context.delete(car)
     }
-
+    
     // Case 3: new object (supposed to be unique) added in the context before the fetch
-
+    
     context.reset()
-
+    
     // first we materialiaze all cars
     XCTAssertNoThrow(try Car.fetch(in: context) { request in request.returnsObjectsAsFaults = false })
     // we add a new car to the context that has an already used numberPlate

      XCTAssertEqual(makers.count, 1)
    }
  }

  func testFailedbatchInsertWithResultObjectIDs() throws {
    guard #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) else { return }

    // Given
    let context = container.viewContext

    let objects = [
      [#keyPath(Car.maker): "FIAT",
       "WRONG_REQUIRED_KEY": "1234",
       #keyPath(Car.model): "Panda"],
    ]

    XCTAssertThrowsError(try Car.batchInsert(using: context, resultType: .objectIDs, objects: objects))
  }

  func testbatchInsertWithDictionaryHandler() throws {
    guard #available(iOS 14.0, tvOS 14.0, watchOS 7.0, macOS 11.0, *) else { return }

    // Given
    let context = container.viewContext

    let dictionaries: [[String: Any]] = [
      [#keyPath(Car.maker): "FIAT", #keyPath(Car.numberPlate): "1", #keyPath(Car.model): "Panda"],
      [#keyPath(Car.maker): "FIAT", #keyPath(Car.numberPlate): "2", #keyPath(Car.model): "Panda"],


final class NSFetchRequestResultUtilsTests: CoreDataPlusOnDiskTestCase {
  // MARK: - Batch Faulting
  
  func testFaultAndMaterializeObjectWithoutNSManagedObjectContext() throws {
    let context = container.viewContext
    
    // Given
    let sportCar1 = SportCar(context: context)
    sportCar1.maker = "McLaren"
    sportCar1.model = "570GT"
    sportCar1.numberPlate = "203"
    try context.save()
    
    context.reset()
    XCTAssertTrue(sportCar1.isFault)
    XCTAssertNil(sportCar1.managedObjectContext)
    
    // When
    try [sportCar1].materializeFaults()
    // Then
    XCTAssertFalse(sportCar1.isFault)
  }
  
  func testFaultAndMaterializeTemporaryObject() throws {
    let context = container.viewContext
    
    // Given
    let sportCar1 = SportCar(context: context)
    sportCar1.maker = "McLaren"
    sportCar1.model = "570GT"
    sportCar1.numberPlate = "203"
    
    XCTAssertTrue(sportCar1.objectID.isTemporaryID)
    XCTAssertFalse(sportCar1.isFault)
    
    // When
    sportCar1.fault()
    // Then
    XCTAssertTrue(sportCar1.isFault)
    
    try [sportCar1].materializeFaults()
    XCTAssertFalse(sportCar1.isFault)
  }
  
  func testBatchFaulting() throws {
    // Given
    let context = container.viewContext
    
    context.performAndWait {
      context.fillWithSampleData()
      try! context.save()
    }
    
    /// re-fault objects that don't have pending changes
    context.refreshAllObjects()
    
    let request = Car.newFetchRequest()
    request.predicate = NSPredicate(value: true)
    
    
    // When
    let cars = try context.fetch(request)
    
    /// re-fault objects that don't have pending changes
    context.refreshAllObjects()
    
    let previousFaultsCount = cars.filter { $0.isFault }.count
    
    /// batch faulting
    XCTAssertNoThrow(try cars.materializeFaults())
    
    // Then
    let currentNotFaultsCount = cars.filter { !$0.isFault }.count
    let currentFaultsCount = cars.filter { $0.isFault }.count
    XCTAssertTrue(previousFaultsCount == currentNotFaultsCount)
    XCTAssertTrue(currentFaultsCount == 0)
    
  }
  
  func testBatchFaultingEdgeCases() throws {
    // Given
    let context = container.viewContext
