         cases.forEach { tc in
             let realm = realmWith(identifier: "t1_\(tc.name)", keyType: tc.keyType)
             
-            insertObject(values: ["identifier": tc.values["identifier"]!, "name": "company1", "sortIndex": 1],
+            insertObject(values: ["identifier": tc.companyIdentifier, "name": "company1", "sortIndex": 1],
                          realm: realm,
                          objectType: tc.companyType)
             

    func testRecordsMarkedForDeletion_deletedObject_returnsRecordID() {
        let cases = TestCase.defaultCases
        cases.forEach { tc in
            let companyId = tc.values["c_id"]!
            let realm = realmWith(identifier: "t4_\(tc.name)", keyType: tc.keyType)
            let company = insertObject(values: ["identifier": companyId, "name": "company1", "sortIndex": 1], realm: realm, objectType: tc.companyType)
            let adapter = realmAdapter(targetConfiguration: realm.configuration, persistenceConfiguration: persistenceConfigurationWith(identifier: "p4_\(tc.name)"))

    // MARK: - Sharing
    
    func testRecordForObjectWithIdentifier_existingObject_returnsRecord() {
        let cases = TestCase.defaultCases
        cases.forEach { tc in
            let (realm, adapter, company, _) = defaultTestObjects(testCase: tc, name: "50")
            let record = adapter.record(for: company!)
            XCTAssertNotNil(record)
            XCTAssertTrue(record!.recordID.recordName.hasPrefix("QSCompany"))
        }
    }
    
    func testShareForObjectWithIdentifier_noShare_returnsNil() {
        let cases = TestCase.defaultCases
        cases.forEach { tc in
            let (realm, adapter, company, _) = defaultTestObjects(testCase: tc, name: "51")
            let share = adapter.share(for: company!)
            XCTAssertNil(share)
        }
    }

    func testShareForObjectWithIdentifier_saveShareCalled_returnsShare() {
        
        let cases = TestCase.defaultCases
        cases.forEach { tc in
            let (realm, adapter, company, _) = defaultTestObjects(testCase: tc, name: "52")
            let record = adapter.record(for: company!)
            let share = CKShare(rootRecord: record!)
            
            adapter.save(share: share, for: company!)
            adapter.save(share: share, for: company!)
            
            let share2 = adapter.share(for: company!)
            XCTAssertNotNil(share2)
        }
    }

    func testShareForObjectWithIdentifier_shareDeleted_returnsNil() {
        
        let cases = TestCase.defaultCases
        cases.forEach { tc in
            let (realm, adapter, company, _) = defaultTestObjects(testCase: tc, name: "53")
            
            let record = adapter.record(for: company!)
            let share = CKShare(rootRecord: record!)
            
            adapter.save(share: share, for: company!)
            
            XCTAssertNotNil(adapter.share(for: company!))
            
            adapter.deleteShare(for: company!)
            
            XCTAssertNil(adapter.share(for: company!))
        }
    }

    func testSaveChangesInRecords_includesShare_savesObjectAndShare() {
        
        let cases = TestCase.defaultCases
        cases.forEach { tc in
            let (realm, adapter, _, _) = defaultTestObjects(testCase: tc, name: "54", insertCompany: false, insertEmployee: false)
            let companyRecord = CKRecord(recordType: String(describing: tc.companyType), recordID: CKRecord.ID(recordName: "\(String(describing: tc.companyType)).\((tc.companyIdentifier as! CustomStringConvertible).description)"))
            companyRecord["name"] = "new company" as NSString
            
            let shareRecord = CKShare(rootRecord: companyRecord, shareID: CKRecord.ID(recordName: "QSShare.forCompany"))
            
            let expectation = self.expectation(description: "synced")
            fullySync(adapter: adapter, downloaded: [companyRecord, shareRecord], deleted: []) { (_, _, _) in
                expectation.fulfill()
            }
            
            waitForExpectations(timeout: 1, handler: nil)
            
            let company = realm.objects(tc.companyType).first
            let share = adapter.share(for: company!)
            
            XCTAssertNotNil(company)
            XCTAssertNotNil(share)
            XCTAssertEqual(company?.value(forKey: "name") as? String, "new company")
            XCTAssertTrue(share?.recordID.recordName == "QSShare.forCompany")
        }
    }

    func testDeleteRecordsWithIDs_containsShare_deletesShare() {
        let cases = TestCase.defaultCases
        cases.forEach { tc in
            let (realm, adapter, company, _) = defaultTestObjects(testCase: tc, name: "55")
            
            let record = adapter.record(for: company!)
            let shareID = CKRecord.ID(recordName: "CKShare.identifier", zoneID: record!.recordID.zoneID)
            let share = CKShare(rootRecord: record!, shareID: shareID)
            
            adapter.save(share: share, for: company!)
            
            let savedShare = adapter.share(for: company!)
            XCTAssertNotNil(savedShare)
            
            let expectation = self.expectation(description: "synced")
            fullySync(adapter: adapter, downloaded: [], deleted: [shareID]) { (_, _, _) in
                expectation.fulfill()
            }
            
            waitForExpectations(timeout: 1, handler: nil)
            
            let updatedShare = adapter.share(for: company!)
            XCTAssertNil(updatedShare)
        }
    }
    
    func testRecordsToUpload_includesAnyParentRecordsInBatch() {
        let cases = TestCase.defaultCases
        cases.forEach { tc in
            let (realm, adapter, company, employee) = defaultTestObjects(testCase: tc, name: "56")
            
            adapter.prepareToImport()
            let records = adapter.recordsToUpload(limit: 1)
            adapter.didFinishImport(with: nil)
            
            XCTAssertEqual(records.count, 2);
            let companyRecord = records.first { $0.recordID.recordName.contains("Company") }
            let employeeRecord = records.first { $0.recordID.recordName.contains("Employee") }
            XCTAssertNotNil(companyRecord)
            XCTAssertNotNil(employeeRecord)
        }
    }
    
    func testRecordsToUpdateParentRelationshipsForRoot_returnsRecords() {
