YohoExplorerDemoTests.m 3.11 KB
//
//  YohoExplorerDemoTests.m
//  YohoExplorerDemoTests
//
//  Created by gaoqiang xu on 2/27/15.
//  Copyright (c) 2015 gaoqiang xu. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "YHLinkDefaultParser.h"

@interface YohoExplorerDemoTests : XCTestCase

@end

@implementation YohoExplorerDemoTests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testLinkParser {
    // This is an example of a functional test case.
    
    YHLinkDefaultParser *parser = [[YHLinkDefaultParser alloc] init];
    
    // 1
    NSString *testUrl1 = @"http://www.baidu.com";
    XCTAssertFalse([parser parseString:testUrl1]);
    
    // 2
    testUrl1 = @"http://www.baidu.com?yohobuy={\"action\":\"go.brand\",\"params\":{\"brand_id\":\"4\"}}";
    XCTAssertFalse([parser parseString:testUrl1]);
    
    // 3
    testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.proudctDetail\",\"params\":{\"product_id\":\"126131\"}}";
    XCTAssertTrue([parser parseString:testUrl1]);
    
    // 4
    testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.coupon\"}";
    XCTAssertTrue([parser parseString:testUrl1]);
    
    // 5
    testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.fav\",\"params\":{\"favType\":\"0\"}}";
    XCTAssertTrue([parser parseString:testUrl1]);
    
    // 6
    testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.mine\"}";
    XCTAssertTrue([parser parseString:testUrl1]);
    
    // 7
    testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.list\",\"params\":{\"msort\":\"1\",\"misort\":\"11\",\"title\":\"上衣\", \"order\":\"s_t_desc\", \"actiontype\":\"1\" , \"query\":\"关键字搜索\", \"gender\":\"1,3\", \"brand\":\"1\", \"color\":\"1\", \"size\":\"12\", \"price\":\"10\", \"page\":\"1\", \"isrecommd\":\"Y\", \"ishot\":\"Y\", \"p_d\":\"0.1, 0.9\"}}";
    XCTAssertTrue([parser parseString:testUrl1]);
    
    // 8
    testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.share\",\"params\":{\"title\":\"分享的标题\",\"content\":\"分享的文字内容\",\"url\":\"分享的URL\",\"pic\":\"图片链接\"}}";
    XCTAssertTrue([parser parseString:testUrl1]);
    
    // 9
    testUrl1 = @"http://www.baidu.com?openby:yohobuy={\"action\":\"go.activity\",\"params\":{\"act_id\":\"4\",\"act_title\":\"春装五折起\", \"islogin\":\"Y\", \"link\":\"http://m.yohobuy.com/get-red-envelope-1111.html\"}}";
    XCTAssertTrue([parser parseString:testUrl1]);
    
    // 10
    YHLinkParserOld *parser1 = [[YHLinkParserOld alloc] init];
    testUrl1 = @"http://www.baidu.com?app:action=go.list,action_id=234234234";
    XCTAssertTrue([parser1 parseString:testUrl1]);
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
        
        
    }];
}

@end