WIP: Fetching unit tests

This commit is contained in:
John Rommel Estropia
2016-06-06 00:12:00 +09:00
parent 02a89accc8
commit b98805e489
13 changed files with 1842 additions and 74 deletions

View File

@@ -181,13 +181,23 @@ public struct From<T: NSManagedObject> {
internal let entityClass: AnyClass
internal let dumpInfo: (key: String, value: Any)?
internal func applyToFetchRequest(fetchRequest: NSFetchRequest, context: NSManagedObjectContext, applyAffectedStores: Bool = true) {
@warn_unused_result
internal func applyToFetchRequest(fetchRequest: NSFetchRequest, context: NSManagedObjectContext, applyAffectedStores: Bool = true) -> Bool {
fetchRequest.entity = context.entityDescriptionForEntityClass(self.entityClass)
if applyAffectedStores {
guard applyAffectedStores else {
self.applyAffectedStoresForFetchedRequest(fetchRequest, context: context)
return true
}
if self.applyAffectedStoresForFetchedRequest(fetchRequest, context: context) {
return true
}
CoreStore.log(
.Warning,
message: "Attempted to perform a fetch but could not find any persistent store for the entity \(cs_typeName(fetchRequest.entityName))"
)
return false
}
internal func applyAffectedStoresForFetchedRequest(fetchRequest: NSFetchRequest, context: NSManagedObjectContext) -> Bool {