unit test for scalar IDs for ImportableUniqueObject

This commit is contained in:
John Rommel Estropia
2017-02-13 22:17:03 +09:00
parent 03973790a8
commit 7baaee493d
3 changed files with 13 additions and 30 deletions

View File

@@ -1083,42 +1083,25 @@ extension TestEntity1: ImportableUniqueObject {
// MARK: ImportableUniqueObject
typealias UniqueIDType = NSNumber
typealias UniqueIDType = Int64
static var uniqueIDKeyPath: String {
return #keyPath(TestEntity1.testEntityID)
}
var uniqueIDValue: NSNumber {
get {
guard let ID = self.testEntityID else {
XCTFail()
return 0
}
return ID
}
set {
self.testEntityID = newValue
}
}
static func shouldUpdate(from source: ImportSource, in transaction: BaseDataTransaction) -> Bool {
return source["skip_update"] == nil
}
static func uniqueID(from source: ImportSource, in transaction: BaseDataTransaction) throws -> NSNumber? {
static func uniqueID(from source: ImportSource, in transaction: BaseDataTransaction) throws -> Int64? {
if let _ = source["throw_on_id"] {
throw TestIDError()
}
return source[(#keyPath(TestEntity1.testEntityID))] as? NSNumber
return source[(#keyPath(TestEntity1.testEntityID))] as? Int64
}
func update(from source: ImportSource, in transaction: BaseDataTransaction) throws {