-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMDDAccessorTests.m
More file actions
59 lines (47 loc) · 1.56 KB
/
MDDAccessorTests.m
File metadata and controls
59 lines (47 loc) · 1.56 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// MDDAccessorTests.m
// MDObjectDatabaseTests
//
// Created by xulinfeng on 2018/3/27.
// Copyright © 2018年 markejave. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "MDDatabaseTestsGlobal.h"
@interface MDDAccessorTests : XCTestCase
@property (nonatomic, strong, readonly) MDDAccessor *accessor;
@property (nonatomic, strong, readonly) dispatch_queue_t queue;
@end
@implementation MDDAccessorTests
- (void)setUp{
[super setUp];
_queue = dispatch_queue_create("com.modool.database", NULL);
_accessor = [[MDDatabaseTestsGlobal database] accessorForClass:[MDDTestClass class] queue:_queue];
}
- (void)testAsynchronize {
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
__block BOOL state = NO;
[[self accessor] async:^(id<MDDProcessor, MDDCoreProcessor> processor) {
state = YES;
XCTAssert(![NSThread isMainThread]);
dispatch_semaphore_signal(semaphore);
}];
dispatch_time_t timeout_nanos = dispatch_time(DISPATCH_TIME_NOW, (10 * NSEC_PER_SEC));
long timeout = dispatch_semaphore_wait(semaphore, timeout_nanos);
XCTAssert(timeout == 0);
XCTAssert(state);
}
- (void)testSynchronize {
__block BOOL state = NO;
[[self accessor] sync:^(id<MDDProcessor, MDDCoreProcessor> processor) {
state = YES;
XCTAssert([NSThread isMainThread]);
}];
XCTAssert(state);
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end