...
|
...
|
@@ -11,7 +11,10 @@ |
|
|
#import "OCMock.h"
|
|
|
#import "YHAssemblyAssistant.h"
|
|
|
|
|
|
@interface YHAssemblyAssistantTests : XCTestCase
|
|
|
@interface YHAssemblyAssistantTests : XCTestCase {
|
|
|
@private
|
|
|
id mock;
|
|
|
}
|
|
|
|
|
|
@end
|
|
|
|
...
|
...
|
@@ -20,16 +23,125 @@ |
|
|
- (void)setUp {
|
|
|
[super setUp];
|
|
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
|
|
NSLog(@"%@ setUp", self.name);
|
|
|
mock = [OCMockObject mockForClass:[YHAssemblyAssistant class]];
|
|
|
XCTAssertNotNil(mock, @"Cannot create YHAssemblyAssistant mock");
|
|
|
}
|
|
|
|
|
|
- (void)tearDown {
|
|
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
|
[super tearDown];
|
|
|
NSLog(@"%@ tearDown", self.name);
|
|
|
}
|
|
|
|
|
|
#pragma mark - self property
|
|
|
|
|
|
- (void)testDeviceNotNil {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
YHAssemblyAssistant *assistant = [[YHAssemblyAssistant alloc] init];
|
|
|
YHDevice *device = [assistant device];
|
|
|
XCTAssertNotNil(device, @"YHAssemblyAssistant device can't be nil.");
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
- (void)testCurrentStatusNotNil {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
YHAssemblyAssistant *assistant = [[YHAssemblyAssistant alloc] init];
|
|
|
YHStatus *status = [assistant currentStatus];
|
|
|
XCTAssertNotNil(status, @"YHAssemblyAssistant status can't be nil.");
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
- (void)testImmediUploadItemDicNotNil {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
YHAssemblyAssistant *assistant = [[YHAssemblyAssistant alloc] init];
|
|
|
NSMutableDictionary *itemDic = [assistant immediUploadItemDic];
|
|
|
XCTAssertNotNil(itemDic, @"YHAssemblyAssistant immediUploadItemDic can't be nil.");
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
#pragma mark - 方法存在性验证
|
|
|
|
|
|
- (void)testCanPersisitingMethod {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
[[[mock stub] andReturnValue:@YES] canPersisiting];
|
|
|
BOOL bPersisting = [mock canPersisiting];
|
|
|
XCTAssert(bPersisting, @"canPersisiting doesn't return YES.");
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
- (void)testExample {
|
|
|
// This is an example of a functional test case.
|
|
|
XCTAssert(YES, @"Pass");
|
|
|
- (void)testSaveItemDataMethodWithConstraint {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
YHAnalyItemData *data = [[YHAnalyItemData alloc] init];
|
|
|
[[mock stub] saveItemData:data];
|
|
|
[mock saveItemData:data];
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
- (void)testGetAllEventCountMethod {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
[[[mock stub] andReturnValue:@10] getAllEventCount];
|
|
|
NSUInteger count = [mock getAllEventCount];
|
|
|
XCTAssertEqual(count, 10, @"YHAssemblyAssistant getAllEventCount doesn't return 10.");
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
- (void)testGetUploadDataMethod {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
NSDictionary *data = @{@"key": @"value"};
|
|
|
[[[mock stub] andReturn:data] getUploadData];
|
|
|
NSDictionary *returndata = [mock getUploadData];
|
|
|
XCTAssertEqualObjects(data, returndata, @"YHAssemblyAssistant getUploadData doesn't return a dictionary with key:value.");
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
- (void)testPrepareImmediUploadDicMethod {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
[[mock stub] prepareImmediUploadDic];
|
|
|
[mock prepareImmediUploadDic];
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
- (void)testUpdateImmediUploadDicMethod {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
[[mock stub] updateImmediUploadDic];
|
|
|
[mock updateImmediUploadDic];
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
- (void)testUploadDiskDataMethod {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
[[mock stub] uploadDiskData];
|
|
|
[mock uploadDiskData];
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
|
|
|
- (void)testUploadImmedilyWithEventMethodWithCOnstraint {
|
|
|
NSLog(@"%@ start", self.name);
|
|
|
|
|
|
YHAnalyItemData *data = [[YHAnalyItemData alloc] init];
|
|
|
[[mock stub] uploadImmedilyWithEvent:data];
|
|
|
[mock uploadImmedilyWithEvent:data];
|
|
|
|
|
|
NSLog(@"%@ end", self.name);
|
|
|
}
|
|
|
@end |
...
|
...
|
|