YHErrorTests.m
2.76 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// YHErrorTests.m
// YH_Analytics
//
// Created by Zhou Rongjun on 15/4/15.
// Copyright (c) 2015年 YOHO. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "OCMock.h"
#import "YHError.h"
@interface YHErrorTests : XCTestCase{
@private
YHError *error;
}
@end
@implementation YHErrorTests
- (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);
error = [[YHError alloc] init];
XCTAssertNotNil(error, @"Cannot create YHError instance.");
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
error = nil;
[super tearDown];
NSLog(@"%@ tearDown", self.name);
}
#pragma mark - super property
- (void)testDataType {
NSLog(@"%@ start", self.name);
YHItemDataType type = [error dataType];
XCTAssert(type == YHItemDataTypeError, @"Error dataType must be YHItemDataTypeError.");
NSLog(@"%@ end", self.name);
}
- (void)testJsonDictionaryNotNil {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [error jsonDictionary];
XCTAssertNotNil(jsonDictionary, @"Error jsonDictionary can't be nil.");
NSLog(@"%@ end", self.name);
}
#pragma mark - value for json key
- (void)testValueForJsonKeyErrorUID {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [error jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyErrorUID];
XCTAssert(value, @"JsonKeyErrorUID value doesn't exist.");
NSLog(@"%@ end", self.name);
}
- (void)testValueForJsonKeyErrorTS {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [error jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyErrorTS];
XCTAssert(value, @"JsonKeyErrorTS value doesn't exist.");
NSLog(@"%@ end", self.name);
}
- (void)testValueForJsonKeyErrorSID {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [error jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyErrorSID];
XCTAssert(value, @"JsonKeyErrorSID value doesn't exist.");
NSLog(@"%@ end", self.name);
}
- (void)testValueForJsonKeyErrorET {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [error jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyErrorET];
XCTAssert(value, @"JsonKeyErrorET value doesn't exist.");
NSLog(@"%@ end", self.name);
}
- (void)testValueForJsonKeyErrorPARAM {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [error jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyErrorPARAM];
XCTAssert(value, @"JsonKeyErrorPARAM value doesn't exist.");
NSLog(@"%@ end", self.name);
}
@end