forked from cocos2d/cocos2d-objc
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCCPackageTests.m
130 lines (108 loc) · 4.88 KB
/
CCPackageTests.m
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//
// CCPackageTests.m
// cocos2d-tests-ios
//
// Created by Nicky Weber on 23.09.14.
// Copyright (c) 2014 Cocos2d. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "CCPackage.h"
#import "CCPackage_private.h"
#import "CCUnitTestHelperMacros.h"
@interface CCPackageTests : XCTestCase
@end
@implementation CCPackageTests
- (void)testInitializer
{
CCPackage *package = [[CCPackage alloc] initWithName:@"DLC"
resolution:@"tablethd"
os:@"iOS"
remoteURL:[NSURL URLWithString:@"http://foo.fake"]];
XCTAssertEqualObjects(package.name, @"DLC");
XCTAssertEqualObjects(package.resolution, @"tablethd");
XCTAssertEqualObjects(package.os, @"iOS");
XCTAssertEqualObjects(package.remoteURL, [NSURL URLWithString:@"http://foo.fake"]);
XCTAssertEqual(package.status, CCPackageStatusInitial);
}
#pragma mark - Tests
- (void)testStandardIdentifier
{
CCPackage *package = [[CCPackage alloc] initWithName:@"DLC"
resolution:@"tablethd"
os:@"iOS"
remoteURL:[NSURL URLWithString:@"http://foo.fake"]];
XCTAssertEqualObjects([package standardIdentifier], @"DLC-iOS-tablethd");
}
- (void)testInitWithDictionary
{
NSDictionary *dictionary = @{
@"name" : @"DLC",
@"resolution" : @"tablethd",
@"os" : @"iOS",
@"remoteURL" : @"http://foo.fake",
@"installURL" : @"Packages",
@"status" : @(CCPackageStatusInstalledDisabled),
@"localDownloadURL" : @"/downloadfolder/baa.zip",
@"localUnzipURL" : @"/unzupfolder/foo",
@"folderName" : @"somename",
@"enableOnDownload" : @(YES)
};
CCPackage *package = [[CCPackage alloc] initWithDictionary:dictionary];
XCTAssertEqualObjects(package.name, @"DLC");
XCTAssertEqualObjects(package.resolution, @"tablethd");
XCTAssertEqualObjects(package.os, @"iOS");
XCTAssertEqualObjects(package.remoteURL, [NSURL URLWithString:@"http://foo.fake"]);
XCTAssertEqualObjects(package.installRelURL, [NSURL fileURLWithPath:@"Packages"]);
XCTAssertEqual(package.status, CCPackageStatusInstalledDisabled);
XCTAssertEqualObjects(package.localDownloadURL, [NSURL fileURLWithPath:@"/downloadfolder/baa.zip"]);
XCTAssertEqualObjects(package.unzipURL, [NSURL fileURLWithPath:@"/unzupfolder/foo"]);
XCTAssertEqualObjects(package.folderName, @"somename");
XCTAssertTrue(package.enableOnDownload);
}
- (void)testInitWithDictionaryMinimumValuesSet
{
NSDictionary *dictionary = @{
@"name" : @"DLC",
@"resolution" : @"tablethd",
@"os" : @"iOS",
@"remoteURL" : @"http://foo.fake",
@"status" : @(CCPackageStatusInitial),
@"enableOnDownload" : @(NO)
};
CCPackage *package = [[CCPackage alloc] initWithDictionary:dictionary];
XCTAssertEqualObjects(package.name, @"DLC");
XCTAssertEqualObjects(package.resolution, @"tablethd");
XCTAssertEqualObjects(package.os, @"iOS");
XCTAssertEqualObjects(package.remoteURL, [NSURL URLWithString:@"http://foo.fake"]);
XCTAssertNil(package.installRelURL);
XCTAssertEqual(package.status, CCPackageStatusInitial);
XCTAssertNil(package.localDownloadURL);
XCTAssertNil(package.unzipURL);
XCTAssertNil(package.folderName);
XCTAssertFalse(package.enableOnDownload);
}
- (void)testToDictionary
{
CCPackage *package = [[CCPackage alloc] initWithName:@"DLC"
resolution:@"tablethd"
os:@"iOS"
remoteURL:[NSURL URLWithString:@"http://foo.fake"]];
package.status = CCPackageStatusInstalledDisabled;
package.installRelURL = [NSURL URLWithString:@"Packages"];
package.unzipURL = [NSURL fileURLWithPath:@"/unzupfolder/foo"];
package.folderName = @"somename";
package.localDownloadURL = [NSURL fileURLWithPath:@"/downloadfolder/baa.zip"];
package.enableOnDownload = NO;
NSDictionary *dictionary = [package toDictionary];
XCTAssertEqualObjects(dictionary[@"name"], @"DLC");
XCTAssertEqualObjects(dictionary[@"resolution"], @"tablethd");
XCTAssertEqualObjects(dictionary[@"os"], @"iOS");
XCTAssertEqualObjects(dictionary[@"remoteURL"], @"http://foo.fake");
XCTAssertEqualObjects(dictionary[@"installURL"], @"Packages");
XCTAssertEqual([dictionary[@"status"] integerValue], CCPackageStatusInstalledDisabled);
XCTAssertEqualObjects(dictionary[@"localDownloadURL"], @"/downloadfolder/baa.zip");
XCTAssertEqualObjects(dictionary[@"localUnzipURL"], @"/unzupfolder/foo");
XCTAssertEqualObjects(dictionary[@"folderName"], @"somename");
XCTAssertFalse([dictionary[@"enableOnDownload"] boolValue]);
}
@end