YHDeviceTests.m 6.32 KB
//
//  YHDeviceTests.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 "YHDevice.h"

@interface YHDeviceTests : XCTestCase {
@private
    YHDevice *device;
}

@end

@implementation YHDeviceTests

- (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);
    device = [[YHDevice alloc] init];
    XCTAssertNotNil(device, @"Cannot create YHDevice instance.");
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    device = nil;
    [super tearDown];
    NSLog(@"%@ tearDown", self.name);
}

#pragma mark - super property

- (void)testDataType {
    NSLog(@"%@ start", self.name);
    YHItemDataType type = [device dataType];
    XCTAssert(type == YHItemDataTypeDevice, @"Device dataType must be YHItemDataTypeDevice.");
    NSLog(@"%@ end", self.name);
}

- (void)testJsonDictionaryNotNil {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    XCTAssertNotNil(jsonDictionary, @"Device jsonDictionary can't be nil.");
    NSLog(@"%@ end", self.name);
}

#pragma mark - self property

- (void)testSvNotNil {
    NSLog(@"%@ start", self.name);
    NSString *sv = [device sv];
    XCTAssertNotNil(sv, @"Device sv can't be nil.");
    NSLog(@"%@ end", self.name);
}

- (void)testChNotNil {
    NSLog(@"%@ start", self.name);
    NSString *ch = [device ch];
    XCTAssertNotNil(ch, @"Device ch can't be nil.");
    NSLog(@"%@ end", self.name);
}

- (void)testOsNotNil {
    NSLog(@"%@ start", self.name);
    NSString *os = [device os];
    XCTAssertNotNil(os, @"Device os can't be nil.");
    NSLog(@"%@ end", self.name);
}

- (void)testOsvNotNil {
    NSLog(@"%@ start", self.name);
    NSString *osv = [device osv];
    XCTAssertNotNil(osv, @"Device osv can't be nil.");
    NSLog(@"%@ end", self.name);
}

- (void)testDmNotNil {
    NSLog(@"%@ start", self.name);
    NSString *dm = [device dm];
    XCTAssertNotNil(dm, @"Device dm can't be nil.");
    NSLog(@"%@ end", self.name);
}

- (void)testUdidNotNil {
    NSLog(@"%@ start", self.name);
    NSString *udid = [device udid];
    XCTAssertNotNil(udid, @"Device udid can't be nil.");
    NSLog(@"%@ end", self.name);
}

- (void)testIfaNotNil {
    NSLog(@"%@ start", self.name);
    NSString *ifa = [device ifa];
    XCTAssertNotNil(ifa, @"Device ifa can't be nil.");
    NSLog(@"%@ end", self.name);
}

- (void)testIfvNotNil {
    NSLog(@"%@ start", self.name);
    NSString *ifv = [device ifv];
    XCTAssertNotNil(ifv, @"Device ifv can't be nil.");
    NSLog(@"%@ end", self.name);
}

- (void)testResNotNil {
    NSLog(@"%@ start", self.name);
    NSString *res = [device res];
    XCTAssertNotNil(res, @"Device res can't be nil.");
    NSLog(@"%@ end", self.name);
}

- (void)testMacNotNil {
    NSLog(@"%@ start", self.name);
    NSString *mac = [device mac];
    XCTAssertNotNil(mac, @"Device mac can't be nil.");
    NSLog(@"%@ end", self.name);
}

#pragma mark - value for json key

- (void)testValueForJsonKeyDeviceSV{
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceSV];
    XCTAssert(value, @"JsonKeyDeviceSV value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceAK {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceAK];
    XCTAssert(value, @"JsonKeyDeviceAK value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceCH {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceCH];
    XCTAssert(value, @"JsonKeyDeviceCH value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceOS {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceOS];
    XCTAssert(value, @"JsonKeyDeviceOS value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceOSV {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceOSV];
    XCTAssert(value, @"JsonKeyDeviceOSV value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceDM {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceDM];
    XCTAssert(value, @"JsonKeyDeviceDM value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceUDID {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceUDID];
    XCTAssert(value, @"JsonKeyDeviceUDID value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceIFA {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceIFA];
    XCTAssert(value, @"JsonKeyDeviceIFA value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceIFV {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceIFV];
    XCTAssert(value, @"JsonKeyDeviceIFV value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceRES {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceRES];
    XCTAssert(value, @"JsonKeyDeviceRES value doesn't exist.");
    NSLog(@"%@ end", self.name);
}

- (void)testValueForJsonKeyDeviceMAC {
    NSLog(@"%@ start", self.name);
    NSDictionary *jsonDictionary = [device jsonDictionary];
    id value = [jsonDictionary objectForKey:JsonKeyDeviceMAC];
    XCTAssert(value, @"JsonKeyDeviceMAC value doesn't exist.");
    NSLog(@"%@ end", self.name);
}
@end