YHEventTests.m
3.06 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
96
97
98
99
100
101
102
103
104
//
// YHEventTests.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 "YHEvent.h"
@interface YHEventTests : XCTestCase {
@private
YHEvent *event;
}
@end
@implementation YHEventTests
- (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);
event = [[YHEvent alloc] init];
XCTAssertNotNil(event, @"Cannot create YHEvent instance.");
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
event = nil;
[super tearDown];
NSLog(@"%@ tearDown", self.name);
}
#pragma mark - super property
- (void)testDataType {
NSLog(@"%@ start", self.name);
YHItemDataType type = [event dataType];
XCTAssert(type == YHItemDataTypeEvent, @"Event dataType must be YHItemDataTypeEvent.");
NSLog(@"%@ end", self.name);
}
- (void)testJsonDictionaryNotNil {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [event jsonDictionary];
XCTAssertNotNil(jsonDictionary, @"Event jsonDictionary can't be nil.");
NSLog(@"%@ end", self.name);
}
#pragma mark - value for json key
- (void)testValueForJsonKeyEventUID{
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [event jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyEventUID];
XCTAssert(value, @"JsonKeyEventUID value doesn't exist.");
NSLog(@"%@ end", self.name);
}
- (void)testValueForJsonKeyEventTS {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [event jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyEventTS];
XCTAssert(value, @"JsonKeyEventTS value doesn't exist.");
NSLog(@"%@ end", self.name);
}
- (void)testValueForJsonKeyEventSID {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [event jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyEventSID];
XCTAssert(value, @"JsonKeyEventSID value doesn't exist.");
NSLog(@"%@ end", self.name);
}
- (void)testValueForJsonKeyEventOP {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [event jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyEventOP];
XCTAssert(value, @"JsonKeyEventOP value doesn't exist.");
NSLog(@"%@ end", self.name);
}
- (void)testValueForJsonKeyEventPARAM {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [event jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyEventPARAM];
XCTAssert(value, @"JsonKeyEventPARAM value doesn't exist.");
NSLog(@"%@ end", self.name);
}
- (void)testValueForJsonKeyEventINDEX {
NSLog(@"%@ start", self.name);
NSDictionary *jsonDictionary = [event jsonDictionary];
id value = [jsonDictionary objectForKey:JsonKeyEventINDEX];
XCTAssert(value, @"JsonKeyEventINDEX value doesn't exist.");
NSLog(@"%@ end", self.name);
}
@end