         let cases = TestCase.defaultCases
         cases.forEach { tc in
             let realm = realmWith(identifier: "t2_\(tc.name)", keyType: tc.keyType)
-            let company = insertObject(values: ["identifier": tc.values["identifier"]!, "name": "company1", "sortIndex": 1], realm: realm, objectType: tc.companyType)
+            let company = insertObject(values: ["identifier": tc.companyIdentifier, "name": "company1", "sortIndex": 1], realm: realm, objectType: tc.companyType)
             let adapter = realmAdapter(targetConfiguration: realm.configuration, persistenceConfiguration: persistenceConfigurationWith(identifier: "p2_\(tc.name)"))
             
             let exp = expectation(description: "synced")

        
        XCTAssertEqual(companies.first?.name, "company1")
    }
    
    // MARK: - Int primary key
    
//    func testRecordsToUploadWithLimit_intKey_initialSync_returnsRecord() {
//        let realm = realmWith(identifier: "t1_int", keyType: .int)
//
//        let object: QSCompany_Int = insertObject(values: ["name": "object 1", "identifier": 1], realm: realm)
//
//        let adapter = realmAdapter(targetConfiguration: realm.configuration, persistenceConfiguration: persistenceConfigurationWith(identifier: "p1_int"))
//
//        let exp = expectation(description: "synced")
//        var uploadedRecord: CKRecord? = nil
//        fullySync(adapter: adapter) { uploaded, _, error in
//            uploadedRecord = uploaded.first
//            exp.fulfill()
//        }
//
//        waitForExpectations(timeout: 1, handler: nil)
//
//        XCTAssertEqual(uploadedRecord?["name"], "object 1")
//        XCTAssertEqual(uploadedRecord?.recordID.recordName, "QSIntKeyObject.1")
//    }
//
//    func testRecordsToUpload_intKey_changedObject_returnsRecordWithChanges() {
//
//        let realm = realmWith(identifier: "t2_int", keyType: .int)
//        let object: QSCompany_Int = insertObject(values: ["name": "object 1", "identifier": 1], realm: realm)
//
//        let adapter = realmAdapter(targetConfiguration: realm.configuration, persistenceConfiguration: persistenceConfigurationWith(identifier: "p2_int"))
//
//        let exp = expectation(description: "synced")
//        fullySync(adapter: adapter) { (uploaded, deleted, error) in
//            exp.fulfill()
//        }
//        waitForExpectations(timeout: 1, handler: nil)
//
//        realm.beginWrite()
//        object.name = "name 2"
//        try! realm.commitWrite()
//
//        waitForHasChangesNotification(from: adapter)
//
//        adapter.prepareToImport()
//        let records = adapter.recordsToUpload(limit: 10)
//        adapter.didFinishImport(with: nil)
//
//        XCTAssertTrue(records.count > 0)
//        let record = records.first!
//        XCTAssertTrue(record["name"] as? String == "name 2")
//    }
    
//    func testSaveChangesInRecord_newObjectWithIntPrimaryKey_insertsObject() {
//
//        let realm = realmWith(identifier: "t101", keyType: .int)
//        let adapter = realmAdapter(targetConfiguration: realm.configuration, persistenceConfiguration: persistenceConfigurationWith(identifier: "p101"))
//
//        let objectRecord = CKRecord(recordType: "QSIntKeyObject", recordID: CKRecord.ID(recordName: "QSIntKeyObject.2"))
//        objectRecord["name"] = "new object" as NSString
//
//        let exp = expectation(description: "merged changes")
//
//        adapter.prepareToImport()
//        adapter.saveChanges(in: [objectRecord])
//        adapter.persistImportedChanges { (_) in
//            exp.fulfill()
//        }
//        adapter.didFinishImport(with: nil)
//
//        waitForExpectations(timeout: 1, handler: nil)
//
//        let objects = realm.objects(QSIntKeyObject.self)
//        XCTAssertTrue(objects.count == 1)
//        let object = objects.first!
//        XCTAssertTrue(object.name == "new object")
//        XCTAssertTrue(object.identifier == 2)
//    }
//
//    func testSaveChangesInRecord_existingObjectWithIntPrimaryKey_updatesObject() {
//
//        let realm = realmWith(identifier: "t102", keyType: .int)
//        let object = QSIntKeyObject()
//        object.name = "object 1"
//        object.identifier = 3
//
//        realm.beginWrite()
//        realm.add(object)
//        try! realm.commitWrite()
//
//        let adapter = realmAdapter(targetConfiguration: realm.configuration, persistenceConfiguration: persistenceConfigurationWith(identifier: "p102"))
//
//        let exp = expectation(description: "synced")
//        var objectRecord: CKRecord?
//
//        fullySync(adapter: adapter) { (uploaded, _, _) in
//            objectRecord = uploaded.first
//            exp.fulfill()
//        }
//        waitForExpectations(timeout: 1, handler: nil)
//
//        objectRecord!["name"] = "name 2" as NSString
//
//        let exp2 = expectation(description: "merged changes")
//
//        adapter.prepareToImport()
//        adapter.saveChanges(in: [objectRecord!])
//        adapter.persistImportedChanges { (_) in
//            exp2.fulfill()
//        }
//        adapter.didFinishImport(with: nil)
//
//        waitForExpectations(timeout: 1, handler: nil)
//
//        XCTAssertTrue(object.name == "name 2")
//        XCTAssertEqual(object.identifier, 3)
//    }
    
    // MARK: - ObjectId primary key
    
//    func testSync_objectWithObjectIdPrimaryKey_canSync() {
//        let realm = realmWith(identifier: "t103", keyType: .objectId)
//
//        let object = QSObjectIdKeyObject()
//        object.name = "object 1"
//        object.identifier = try! ObjectId(string: "608efbc93ad7a4c09f8fdaa5")
//
//        realm.beginWrite()
//        realm.add(object)
//        try! realm.commitWrite()
//
//        let adapter = realmAdapter(targetConfiguration: realm.configuration, persistenceConfiguration: persistenceConfigurationWith(identifier: "p103"))
//
//        let exp = expectation(description: "synced")
//        var uploadedRecord: CKRecord? = nil
//        fullySync(adapter: adapter) { uploaded, _, error in
//            uploadedRecord = uploaded.first
//            exp.fulfill()
//        }
//
//        waitForExpectations(timeout: 1, handler: nil)
//
//        XCTAssertEqual(uploadedRecord?["name"], "object 1")
//        XCTAssertEqual(uploadedRecord?.recordID.recordName, "QSObjectIdKeyObject.608efbc93ad7a4c09f8fdaa5")
//    }
//
//    func testSaveChangesInRecord_newObjectWithObjectIdPrimaryKey_insertsObject() {
//
//        let realm = realmWith(identifier: "t104", keyType: .objectId)
//        let adapter = realmAdapter(targetConfiguration: realm.configuration, persistenceConfiguration: persistenceConfigurationWith(identifier: "p104"))
//
//        let objectRecord = CKRecord(recordType: "QSObjectIdKeyObject", recordID: CKRecord.ID(recordName: "QSObjectIdKeyObject.608efbc93ad7a4c09f8fdaa5"))
//        objectRecord["name"] = "new object" as NSString
//
//        let exp = expectation(description: "merged changes")
//
//        adapter.prepareToImport()
//        adapter.saveChanges(in: [objectRecord])
//        adapter.persistImportedChanges { (_) in
//            exp.fulfill()
//        }
//        adapter.didFinishImport(with: nil)
//
//        waitForExpectations(timeout: 1, handler: nil)
//
//        let objects = realm.objects(QSObjectIdKeyObject.self)
//        XCTAssertTrue(objects.count == 1)
//        let object = objects.first!
//        let id = try! ObjectId(string: "608efbc93ad7a4c09f8fdaa5")
//        XCTAssertTrue(object.name == "new object")
//        XCTAssertTrue(object.identifier == id)
//    }
//
//    func testSaveChangesInRecord_existingObjectWithObjectIdPrimaryKey_updatesObject() {
//
//        let realm = realmWith(identifier: "t105", keyType: .objectId)
//        let object = QSObjectIdKeyObject()
//        object.name = "object 1"
//        object.identifier = try! ObjectId(string: "608efbc93ad7a4c09f8fdaa5")
//
//        realm.beginWrite()
//        realm.add(object)
//        try! realm.commitWrite()
//
//        let adapter = realmAdapter(targetConfiguration: realm.configuration, persistenceConfiguration: persistenceConfigurationWith(identifier: "p105"))
//
//        let exp = expectation(description: "synced")
//        var objectRecord: CKRecord?
//
//        fullySync(adapter: adapter) { (uploaded, _, _) in
//            objectRecord = uploaded.first
//            exp.fulfill()
//        }
//        waitForExpectations(timeout: 1, handler: nil)
//
//        objectRecord!["name"] = "name 2" as NSString
//
//        let exp2 = expectation(description: "merged changes")
//
//        adapter.prepareToImport()
//        adapter.saveChanges(in: [objectRecord!])
//        adapter.persistImportedChanges { (_) in
//            exp2.fulfill()
//        }
//        adapter.didFinishImport(with: nil)
//
//        waitForExpectations(timeout: 1, handler: nil)
//
//        XCTAssertTrue(object.name == "name 2")
//    }
}

    func testSaveChangesInRecord_existingObject_updatesObject() {
        let cases = TestCase.defaultCases
        cases.forEach { tc in
            let companyId = tc.companyIdentifier
            let realm = realmWith(identifier: "t6_\(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: "p6_\(tc.name)"))
