-
Notifications
You must be signed in to change notification settings - Fork 6
/
StoredModelTest.m
27 lines (21 loc) · 957 Bytes
/
StoredModelTest.m
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
//
// StoredModelTest.m
// StoredModel
#import "StoredModelTest.h"
#import "StoredModel.h"
@implementation StoredModelTest
- (void)setUp {
model = [[NSManagedObjectModel mergedModelFromBundles:
[NSArray arrayWithObject:[NSBundle bundleWithIdentifier:@"com.yourcompany.tests"]]] retain];
coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
context = [[NSManagedObjectContext alloc] init];
[context setPersistentStoreCoordinator:coordinator];
NSURL *storeUrl = [NSURL fileURLWithPath: [NSTemporaryDirectory() stringByAppendingPathComponent: @"stored_model_test"]];
NSError *error = nil;
[[NSFileManager defaultManager] removeItemAtPath:storeUrl.path error:&error];
if (![coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) {
NSLog(@"Error creating store: %@", error);
}
[StoredModel setContext:context];
}
@end