forked from QueryKit/QueryKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryKitTests.swift
More file actions
44 lines (36 loc) · 1.33 KB
/
Copy pathQueryKitTests.swift
File metadata and controls
44 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// QueryKitTests.swift
// QueryKitTests
//
// Created by Kyle Fuller on 19/06/2014.
//
//
import XCTest
import QueryKit
@objc(Person) class Person : NSManagedObject {
@NSManaged var name:String
}
extension Person {
class func create(context:NSManagedObjectContext) -> Person {
return NSEntityDescription.insertNewObjectForEntityForName(Person.className(), inManagedObjectContext: context) as Person
}
}
func managedObjectModel() -> NSManagedObjectModel {
let personEntity = NSEntityDescription()
personEntity.name = Person.className()
personEntity.managedObjectClassName = Person.className()
let personNameAttribute = NSAttributeDescription()
personNameAttribute.name = "name"
personNameAttribute.attributeType = NSAttributeType.StringAttributeType
personNameAttribute.optional = false
personEntity.properties = [personNameAttribute]
let model = NSManagedObjectModel()
model.entities = [personEntity]
return model
}
func persistentStoreCoordinator() -> NSPersistentStoreCoordinator {
let model = managedObjectModel()
let persistentStoreCoordinator = NSPersistentStoreCoordinator(managedObjectModel: model)
persistentStoreCoordinator.addPersistentStoreWithType(NSInMemoryStoreType, configuration: nil, URL: nil, options: nil, error: nil)
return persistentStoreCoordinator
}