Skip to content

Commit 4f1ef60

Browse files
committed
Unit tests added for CCPackageInstallData and CCPackage+InstallData category.
File skeletons for other package classes added. Moved two methods from CCPackage+InstallData to CCPackageInstallData.
1 parent 3c08964 commit 4f1ef60

16 files changed

+553
-70
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// CCPackage+InstallDataTests.m
3+
// cocos2d-tests-ios
4+
//
5+
// Created by Nicky Weber on 23.09.14.
6+
// Copyright (c) 2014 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "CCPackage.h"
11+
#import "CCPackageInstallData.h"
12+
#import "CCPackage+InstallData.h"
13+
14+
@interface CCPackage_InstallDataTests : XCTestCase
15+
16+
@property (nonatomic, strong) CCPackage *package;
17+
@property (nonatomic, strong) CCPackageInstallData *installData;
18+
19+
@end
20+
21+
22+
@implementation CCPackage_InstallDataTests
23+
24+
- (void)setUp
25+
{
26+
[super setUp];
27+
28+
self.package = [[CCPackage alloc] initWithName:@"Foo"
29+
resolution:@"phonehd"
30+
os:@"iOS"
31+
remoteURL:[NSURL URLWithString:@"http://foo.fake/Foo-iOS-phonehd.zip"]];
32+
33+
self.installData = [[CCPackageInstallData alloc] initWithPackage:_package];
34+
}
35+
36+
- (void)testSetAndGetInstallData
37+
{
38+
[_package setInstallData:_installData];
39+
CCPackageInstallData *installDataGet = [_package installData];
40+
XCTAssertTrue(_installData == installDataGet, @"InstallData set is not the same as the retrieved one.");
41+
}
42+
43+
- (void)testRemoveInstallData
44+
{
45+
[_package setInstallData:_installData];
46+
[_package removeInstallData];
47+
CCPackageInstallData *installDataGet = [_package installData];
48+
XCTAssertNil(installDataGet, @"Retrieved installData should be nil.");
49+
}
50+
51+
@end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CCPackageCocos2dEnablerTests.m
3+
// cocos2d-tests-ios
4+
//
5+
// Created by Nicky Weber on 23.09.14.
6+
// Copyright (c) 2014 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface CCPackageCocos2dEnablerTests : XCTestCase
12+
13+
@end
14+
15+
@implementation CCPackageCocos2dEnablerTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
// Put setup code here. This method is called before the invocation of each test method in the class.
21+
}
22+
23+
- (void)tearDown
24+
{
25+
// Put teardown code here. This method is called after the invocation of each test method in the class.
26+
[super tearDown];
27+
}
28+
29+
- (void)testExample
30+
{
31+
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32+
}
33+
34+
@end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CCPackageDownloadManagerTests.m
3+
// cocos2d-tests-ios
4+
//
5+
// Created by Nicky Weber on 23.09.14.
6+
// Copyright (c) 2014 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface CCPackageDownloadManagerTests : XCTestCase
12+
13+
@end
14+
15+
@implementation CCPackageDownloadManagerTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
// Put setup code here. This method is called before the invocation of each test method in the class.
21+
}
22+
23+
- (void)tearDown
24+
{
25+
// Put teardown code here. This method is called after the invocation of each test method in the class.
26+
[super tearDown];
27+
}
28+
29+
- (void)testExample
30+
{
31+
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32+
}
33+
34+
@end

UnitTests/CCPackageDownloadTests.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CCPackageDownloadTests.m
3+
// cocos2d-tests-ios
4+
//
5+
// Created by Nicky Weber on 23.09.14.
6+
// Copyright (c) 2014 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface CCPackageDownloadTests : XCTestCase
12+
13+
@end
14+
15+
@implementation CCPackageDownloadTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
// Put setup code here. This method is called before the invocation of each test method in the class.
21+
}
22+
23+
- (void)tearDown
24+
{
25+
// Put teardown code here. This method is called after the invocation of each test method in the class.
26+
[super tearDown];
27+
}
28+
29+
- (void)testExample
30+
{
31+
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32+
}
33+
34+
@end

UnitTests/CCPackageHelperTests.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CCPackageHelperTests.m
3+
// cocos2d-tests-ios
4+
//
5+
// Created by Nicky Weber on 23.09.14.
6+
// Copyright (c) 2014 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface CCPackageHelperTests : XCTestCase
12+
13+
@end
14+
15+
@implementation CCPackageHelperTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
// Put setup code here. This method is called before the invocation of each test method in the class.
21+
}
22+
23+
- (void)tearDown
24+
{
25+
// Put teardown code here. This method is called after the invocation of each test method in the class.
26+
[super tearDown];
27+
}
28+
29+
- (void)testExample
30+
{
31+
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32+
}
33+
34+
@end

UnitTests/CCPackageInstallDataTests.m

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//
2+
// CCPackageInstallDataTests.m
3+
// cocos2d-tests-ios
4+
//
5+
// Created by Nicky Weber on 24.09.14.
6+
// Copyright (c) 2014 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import <Foundation/Foundation.h>
11+
#import "CCPackageInstallData.h"
12+
#import "CCPackage.h"
13+
14+
@interface CCPackageInstallDataTests : XCTestCase
15+
16+
@property (nonatomic, strong) CCPackageInstallData *installData;
17+
18+
@end
19+
20+
21+
@implementation CCPackageInstallDataTests
22+
23+
- (void)setUp
24+
{
25+
[super setUp];
26+
27+
CCPackage *package = [[CCPackage alloc] initWithName:@"Foo"
28+
resolution:@"phonehd"
29+
os:@"iOS"
30+
remoteURL:[NSURL URLWithString:@"http://foo.fake/Foo-iOS-phonehd.zip"]];
31+
32+
self.installData = [[CCPackageInstallData alloc] initWithPackage:package];
33+
_installData.unzipURL = [NSURL fileURLWithPath:@"/unzupfolder/foo"];
34+
_installData.folderName = @"somename";
35+
_installData.localDownloadURL = [NSURL fileURLWithPath:@"/downloadfolder/baa.zip"];
36+
_installData.enableOnDownload = NO;
37+
38+
}
39+
40+
- (void)testPopulateInstallDataWithDictionary
41+
{
42+
// Constants for dict keys are only used internally, not making them public
43+
NSDictionary *installDataDict = @{
44+
@"localDownloadURL" : @"file:///downloadfolder/baa.zip",
45+
@"localUnzipURL" : @"file:///unzupfolder/foo",
46+
@"folderName" : @"somename",
47+
@"enableOnDownload" : @(YES)
48+
};
49+
50+
[_installData populateInstallDataWithDictionary:installDataDict];
51+
52+
NSURL *localDownloadURL = [NSURL fileURLWithPath:@"/downloadfolder/baa.zip"];
53+
XCTAssertTrue([_installData.localDownloadURL isEqual:localDownloadURL], @"%@ is not equal to %@", _installData.localDownloadURL, localDownloadURL);
54+
55+
NSURL *unzipURL = [NSURL fileURLWithPath:@"/unzupfolder/foo"];
56+
XCTAssertTrue([_installData.unzipURL isEqual:unzipURL], @"%@ is not equal to %@", _installData.unzipURL, unzipURL);
57+
58+
NSString *folderName = @"somename";
59+
XCTAssertTrue([_installData.folderName isEqual:folderName], @"%@ is not equal to %@", _installData.folderName, folderName);
60+
61+
XCTAssertTrue(_installData.enableOnDownload);
62+
}
63+
64+
- (void)testWriteInstallDataToDictionary
65+
{
66+
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
67+
68+
[_installData writeInstallDataToDictionary:dictionary];
69+
70+
NSURL *localDownloadURL = [NSURL fileURLWithPath:@"/downloadfolder/baa.zip"];
71+
NSURL *dictDownloadURL = [NSURL URLWithString:dictionary[@"localDownloadURL"]];
72+
XCTAssertTrue([dictDownloadURL isEqual:localDownloadURL], @"%@ is not equal to %@", dictDownloadURL, localDownloadURL);
73+
74+
NSURL *localUnzipURL = [NSURL fileURLWithPath:@"/unzupfolder/foo"];
75+
NSURL *dictUnzipURL = [NSURL URLWithString:dictionary[@"localUnzipURL"]];
76+
XCTAssertTrue([dictUnzipURL isEqual:localUnzipURL], @"%@ is not equal to %@", dictUnzipURL, localUnzipURL);
77+
78+
NSString *localFolderName = @"somename";
79+
NSString *dictFolderName = dictionary[@"folderName"];
80+
XCTAssertTrue([dictFolderName isEqualToString:localFolderName], @"%@ is not equal to %@", dictFolderName, localFolderName);
81+
82+
XCTAssertFalse([dictionary[@"enableOnDownload"] boolValue]);
83+
}
84+
85+
@end

UnitTests/CCPackageInstallerTests.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CCPackageInstallerTests.m
3+
// cocos2d-tests-ios
4+
//
5+
// Created by Nicky Weber on 23.09.14.
6+
// Copyright (c) 2014 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface CCPackageInstallerTests : XCTestCase
12+
13+
@end
14+
15+
@implementation CCPackageInstallerTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
// Put setup code here. This method is called before the invocation of each test method in the class.
21+
}
22+
23+
- (void)tearDown
24+
{
25+
// Put teardown code here. This method is called after the invocation of each test method in the class.
26+
[super tearDown];
27+
}
28+
29+
- (void)testExample
30+
{
31+
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32+
}
33+
34+
@end

UnitTests/CCPackageManagerTests.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CCPackageManagerTests.m
3+
// cocos2d-tests-ios
4+
//
5+
// Created by Nicky Weber on 23.09.14.
6+
// Copyright (c) 2014 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface CCPackageManagerTests : XCTestCase
12+
13+
@end
14+
15+
@implementation CCPackageManagerTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
// Put setup code here. This method is called before the invocation of each test method in the class.
21+
}
22+
23+
- (void)tearDown
24+
{
25+
// Put teardown code here. This method is called after the invocation of each test method in the class.
26+
[super tearDown];
27+
}
28+
29+
- (void)testExample
30+
{
31+
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32+
}
33+
34+
@end

UnitTests/CCPackageTests.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// CCPackageTests.m
3+
// cocos2d-tests-ios
4+
//
5+
// Created by Nicky Weber on 23.09.14.
6+
// Copyright (c) 2014 Cocos2d. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
11+
@interface CCPackageTests : XCTestCase
12+
13+
@end
14+
15+
@implementation CCPackageTests
16+
17+
- (void)setUp
18+
{
19+
[super setUp];
20+
// Put setup code here. This method is called before the invocation of each test method in the class.
21+
}
22+
23+
- (void)tearDown
24+
{
25+
// Put teardown code here. This method is called after the invocation of each test method in the class.
26+
[super tearDown];
27+
}
28+
29+
- (void)testExample
30+
{
31+
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32+
}
33+
34+
@end

0 commit comments

Comments
 (0)