|
7 | 7 | //
|
8 | 8 |
|
9 | 9 | #import <XCTest/XCTest.h>
|
| 10 | +#import "CCPackage.h" |
| 11 | +#import "CCUnitTestAssertions.h" |
10 | 12 |
|
11 | 13 | @interface CCPackageTests : XCTestCase
|
12 | 14 |
|
13 | 15 | @end
|
14 | 16 |
|
| 17 | + |
15 | 18 | @implementation CCPackageTests
|
16 | 19 |
|
17 |
| -- (void)setUp |
| 20 | +- (void)testInitializer |
18 | 21 | {
|
19 |
| - [super setUp]; |
20 |
| - // Put setup code here. This method is called before the invocation of each test method in the class. |
| 22 | + CCPackage *package = [[CCPackage alloc] initWithName:@"DLC" |
| 23 | + resolution:@"tablethd" |
| 24 | + os:@"iOS" |
| 25 | + remoteURL:[NSURL URLWithString:@"http://foo.fake"]]; |
| 26 | + |
| 27 | + CCAssertEqualStrings(package.name, @"DLC"); |
| 28 | + CCAssertEqualStrings(package.resolution, @"tablethd"); |
| 29 | + CCAssertEqualStrings(package.os, @"iOS"); |
| 30 | + XCTAssertEqualObjects(package.remoteURL, [NSURL URLWithString:@"http://foo.fake"]); |
| 31 | + XCTAssertEqual(package.status, CCPackageStatusInitial); |
21 | 32 | }
|
22 | 33 |
|
23 |
| -- (void)tearDown |
| 34 | +- (void)testStandardIdentifier |
24 | 35 | {
|
25 |
| - // Put teardown code here. This method is called after the invocation of each test method in the class. |
26 |
| - [super tearDown]; |
| 36 | + CCPackage *package = [[CCPackage alloc] initWithName:@"DLC" |
| 37 | + resolution:@"tablethd" |
| 38 | + os:@"iOS" |
| 39 | + remoteURL:[NSURL URLWithString:@"http://foo.fake"]]; |
| 40 | + |
| 41 | + CCAssertEqualStrings([package standardIdentifier], @"DLC-iOS-tablethd"); |
27 | 42 | }
|
28 | 43 |
|
29 |
| -- (void)testExample |
| 44 | +- (void)testInitWithDictionary |
30 | 45 | {
|
31 |
| - XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); |
| 46 | + NSDictionary *dictionary = @{ |
| 47 | + @"name" : @"DLC", |
| 48 | + @"resolution" : @"tablethd", |
| 49 | + @"os" : @"iOS", |
| 50 | + @"remoteURL" : @"http://foo.fake", |
| 51 | + @"installURL" : @"/Library/Caches/Packages", |
| 52 | + @"status" : @(CCPackageStatusInstalledDisabled), |
| 53 | + }; |
| 54 | + |
| 55 | + CCPackage *package = [[CCPackage alloc] initWithDictionary:dictionary]; |
| 56 | + |
| 57 | + CCAssertEqualStrings(package.name, @"DLC"); |
| 58 | + CCAssertEqualStrings(package.resolution, @"tablethd"); |
| 59 | + CCAssertEqualStrings(package.os, @"iOS"); |
| 60 | + XCTAssertEqualObjects(package.remoteURL, [NSURL URLWithString:@"http://foo.fake"]); |
| 61 | + XCTAssertEqualObjects(package.installURL, [NSURL fileURLWithPath:@"/Library/Caches/Packages"]); |
| 62 | + XCTAssertEqual(package.status, CCPackageStatusInstalledDisabled); |
| 63 | +} |
| 64 | + |
| 65 | +- (void)testToDictionary |
| 66 | +{ |
| 67 | + CCPackage *package = [[CCPackage alloc] initWithName:@"DLC" |
| 68 | + resolution:@"tablethd" |
| 69 | + os:@"iOS" |
| 70 | + remoteURL:[NSURL URLWithString:@"http://foo.fake"]]; |
| 71 | + |
| 72 | + [package setValue:@(CCPackageStatusInstalledDisabled) forKey:@"status"]; |
| 73 | + [package setValue:[NSURL fileURLWithPath:@"/Library/Caches/Packages"] forKey:@"installURL"]; |
| 74 | + |
| 75 | + NSDictionary *dictionary = [package toDictionary]; |
| 76 | + |
| 77 | + CCAssertEqualStrings(dictionary[@"name"], @"DLC"); |
| 78 | + CCAssertEqualStrings(dictionary[@"resolution"], @"tablethd"); |
| 79 | + CCAssertEqualStrings(dictionary[@"os"], @"iOS"); |
| 80 | + CCAssertEqualStrings(dictionary[@"remoteURL"], @"http://foo.fake"); |
| 81 | + CCAssertEqualStrings(dictionary[@"installURL"], @"/Library/Caches/Packages"); |
| 82 | + XCTAssertEqual([dictionary[@"status"] integerValue], CCPackageStatusInstalledDisabled); |
32 | 83 | }
|
33 | 84 |
|
34 | 85 | @end
|
0 commit comments