YHEventTests.m 3.04 KB
//
//  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 "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