8
8
9
9
#import < XCTest/XCTest.h>
10
10
#import " CCPackage.h"
11
+ #import " CCPackage_private.h"
11
12
#import " CCUnitTestAssertions.h"
13
+ #import " CCPackage+InstallData.h"
12
14
13
15
@interface CCPackageTests : XCTestCase
14
16
@@ -53,6 +55,10 @@ - (void)testInitWithDictionary
53
55
@" remoteURL" : @" http://foo.fake" ,
54
56
@" installURL" : @" /Library/Caches/Packages" ,
55
57
@" status" : @(CCPackageStatusInstalledDisabled),
58
+ @" localDownloadURL" : @" /downloadfolder/baa.zip" ,
59
+ @" localUnzipURL" : @" /unzupfolder/foo" ,
60
+ @" folderName" : @" somename" ,
61
+ @" enableOnDownload" : @(YES )
56
62
};
57
63
58
64
CCPackage *package = [[CCPackage alloc ] initWithDictionary: dictionary];
@@ -63,6 +69,10 @@ - (void)testInitWithDictionary
63
69
XCTAssertEqualObjects (package.remoteURL , [NSURL URLWithString: @" http://foo.fake" ]);
64
70
XCTAssertEqualObjects (package.installURL , [NSURL fileURLWithPath: @" /Library/Caches/Packages" ]);
65
71
XCTAssertEqual (package.status , CCPackageStatusInstalledDisabled);
72
+ XCTAssertEqualObjects (package.localDownloadURL , [NSURL fileURLWithPath: @" /downloadfolder/baa.zip" ]);
73
+ XCTAssertEqualObjects (package.unzipURL , [NSURL fileURLWithPath: @" /unzupfolder/foo" ]);
74
+ CCAssertEqualStrings (package.folderName , @" somename" );
75
+ XCTAssertTrue (package.enableOnDownload );
66
76
}
67
77
68
78
- (void )testToDictionary
@@ -72,8 +82,12 @@ - (void)testToDictionary
72
82
os: @" iOS"
73
83
remoteURL: [NSURL URLWithString: @" http://foo.fake" ]];
74
84
75
- [package setValue: @(CCPackageStatusInstalledDisabled) forKey: @" status" ];
76
- [package setValue: [NSURL fileURLWithPath: @" /Library/Caches/Packages" ] forKey: @" installURL" ];
85
+ package.status = CCPackageStatusInstalledDisabled;
86
+ package.installURL = [NSURL fileURLWithPath: @" /Library/Caches/Packages" ];
87
+ package.unzipURL = [NSURL fileURLWithPath: @" /unzupfolder/foo" ];
88
+ package.folderName = @" somename" ;
89
+ package.localDownloadURL = [NSURL fileURLWithPath: @" /downloadfolder/baa.zip" ];
90
+ package.enableOnDownload = NO ;
77
91
78
92
NSDictionary *dictionary = [package toDictionary ];
79
93
@@ -83,6 +97,10 @@ - (void)testToDictionary
83
97
CCAssertEqualStrings (dictionary[@" remoteURL" ], @" http://foo.fake" );
84
98
CCAssertEqualStrings (dictionary[@" installURL" ], @" /Library/Caches/Packages" );
85
99
XCTAssertEqual ([dictionary[@" status" ] integerValue ], CCPackageStatusInstalledDisabled);
100
+ CCAssertEqualStrings (dictionary[@" localDownloadURL" ], @" /downloadfolder/baa.zip" );
101
+ CCAssertEqualStrings (dictionary[@" localUnzipURL" ], @" /unzupfolder/foo" );
102
+ CCAssertEqualStrings (dictionary[@" folderName" ], @" somename" );
103
+ XCTAssertFalse ([dictionary[@" enableOnDownload" ] boolValue ]);
86
104
}
87
105
88
106
@end
0 commit comments