-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d5f741
commit 59b2bde
Showing
38 changed files
with
606 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#import <XCTest/XCTest.h> | ||
#import "UADSLoadOptions.h" | ||
|
||
@interface LoadOptionsTest : XCTestCase | ||
|
||
@property UADSLoadOptions* loadOptions; | ||
|
||
@end | ||
|
||
@implementation LoadOptionsTest | ||
|
||
- (void)setUp { | ||
self.loadOptions = [UADSLoadOptions new]; | ||
} | ||
|
||
- (void)tearDown { | ||
self.loadOptions = nil; | ||
} | ||
|
||
- (void)testAdMarkup { | ||
[self.loadOptions setAdMarkup:@"MyAdMarkup"]; | ||
|
||
XCTAssertEqual(@"MyAdMarkup", [self.loadOptions adMarkup]); | ||
XCTAssertEqual(@"MyAdMarkup", [self.loadOptions.dictionary objectForKey:@"adMarkup"]); | ||
|
||
XCTAssertEqual(1, [self.loadOptions.dictionary count]); | ||
} | ||
|
||
- (void)testObjectId { | ||
[self.loadOptions setObjectId:@"MyObjectId"]; | ||
|
||
XCTAssertEqual(@"MyObjectId", [self.loadOptions objectId]); | ||
XCTAssertEqual(@"MyObjectId", [self.loadOptions.dictionary objectForKey:@"objectId"]); | ||
|
||
XCTAssertEqual(1, [self.loadOptions.dictionary count]); | ||
} | ||
|
||
- (void)testObjectIdAndAdMarkup { | ||
[self.loadOptions setObjectId:@"MyObjectId"]; | ||
[self.loadOptions setAdMarkup:@"MyAdMarkup"]; | ||
|
||
XCTAssertEqual(@"MyObjectId", [self.loadOptions objectId]); | ||
XCTAssertEqual(@"MyObjectId", [self.loadOptions.dictionary objectForKey:@"objectId"]); | ||
|
||
XCTAssertEqual(@"MyAdMarkup", [self.loadOptions adMarkup]); | ||
XCTAssertEqual(@"MyAdMarkup", [self.loadOptions.dictionary objectForKey:@"adMarkup"]); | ||
|
||
XCTAssertEqual(2, [self.loadOptions.dictionary count]); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#import <XCTest/XCTest.h> | ||
#import "UADSShowOptions.h" | ||
|
||
@interface ShowOptionsTest : XCTestCase | ||
|
||
@property UADSShowOptions* showOptions; | ||
|
||
@end | ||
|
||
@implementation ShowOptionsTest | ||
|
||
- (void)setUp { | ||
self.showOptions = [UADSShowOptions new]; | ||
} | ||
|
||
- (void)tearDown { | ||
self.showOptions = nil; | ||
} | ||
|
||
- (void)testObjectId { | ||
[self.showOptions setObjectId:@"MyObjectId"]; | ||
XCTAssertEqual(@"MyObjectId", [self.showOptions objectId]); | ||
XCTAssertEqual(@"MyObjectId", [self.showOptions.dictionary objectForKey:@"objectId"]); | ||
XCTAssertEqual(1, [self.showOptions.dictionary count]); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#import <XCTest/XCTest.h> | ||
#import "UnityAdsTests-Bridging-Header.h" | ||
|
||
@interface TokenStorageEventHandlerMock : NSObject<UADSTokenStorageEventProtocol> | ||
|
||
@property int queueEmptyCount; | ||
@property int accessTokenCount; | ||
@property NSMutableArray* indecies; | ||
|
||
- (void) sendQueueEmpty; | ||
- (void) sendTokenAccessIndex:(NSNumber*)index; | ||
|
||
@end | ||
|
||
@implementation TokenStorageEventHandlerMock | ||
|
||
- (void) sendQueueEmpty { | ||
self.queueEmptyCount++; | ||
} | ||
|
||
- (void) sendTokenAccessIndex:(NSNumber*)index { | ||
self.accessTokenCount++; | ||
|
||
if (self.indecies == nil) { | ||
self.indecies = [NSMutableArray new]; | ||
} | ||
|
||
[self.indecies addObject:index]; | ||
} | ||
|
||
@end | ||
|
||
@interface TokenStorageTests : XCTestCase | ||
|
||
@property UADSTokenStorage* tokenStorage; | ||
@property TokenStorageEventHandlerMock* eventHandlerMock; | ||
|
||
@end | ||
|
||
@implementation TokenStorageTests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
|
||
self.eventHandlerMock = [TokenStorageEventHandlerMock new]; | ||
self.tokenStorage = [[UADSTokenStorage alloc] initWithEventHandler:self.eventHandlerMock]; | ||
} | ||
|
||
- (void)tearDown { | ||
[super tearDown]; | ||
} | ||
|
||
- (void)testCreateToken { | ||
[self.tokenStorage createTokens:@[@"token1", @"token2", @"token3"]]; | ||
|
||
XCTAssertEqual([self.tokenStorage getToken], @"token1"); | ||
XCTAssertEqual([self.tokenStorage getToken], @"token2"); | ||
XCTAssertEqual([self.tokenStorage getToken], @"token3"); | ||
XCTAssertEqual([self.tokenStorage getToken], nil); | ||
} | ||
|
||
- (void)testDeleteToken { | ||
[self.tokenStorage createTokens:@[@"token1", @"token2", @"token3"]]; | ||
[self.tokenStorage deleteTokens]; | ||
|
||
XCTAssertEqual([self.tokenStorage getToken], nil); | ||
} | ||
|
||
- (void)testAppendToken { | ||
[self.tokenStorage createTokens:@[@"token1"]]; | ||
[self.tokenStorage appendTokens:@[@"token2", @"token3"]]; | ||
|
||
XCTAssertEqual([self.tokenStorage getToken], @"token1"); | ||
XCTAssertEqual([self.tokenStorage getToken], @"token2"); | ||
XCTAssertEqual([self.tokenStorage getToken], @"token3"); | ||
XCTAssertEqual([self.tokenStorage getToken], nil); | ||
} | ||
|
||
- (void)testAppendTokenOnEmptyStorage { | ||
[self.tokenStorage deleteTokens]; | ||
[self.tokenStorage appendTokens:@[@"token1", @"token2"]]; | ||
|
||
XCTAssertEqual([self.tokenStorage getToken], @"token1"); | ||
XCTAssertEqual([self.tokenStorage getToken], @"token2"); | ||
XCTAssertEqual([self.tokenStorage getToken], nil); | ||
} | ||
|
||
- (void)testAppendTokenWithoutQueueShouldNotCrashApp { | ||
[self.tokenStorage appendTokens:@[@"token2", @"token3"]]; | ||
} | ||
|
||
|
||
- (void)testGetTokenWhenNoQueue { | ||
XCTAssertEqual([self.tokenStorage getToken], nil); | ||
XCTAssertEqual(self.eventHandlerMock.queueEmptyCount, 0); | ||
XCTAssertEqual(self.eventHandlerMock.accessTokenCount, 0); | ||
} | ||
|
||
- (void)testGetTokenAccessToken { | ||
[self.tokenStorage createTokens:@[@"token1"]]; | ||
|
||
XCTAssertEqual([self.tokenStorage getToken], @"token1"); | ||
XCTAssertEqual(self.eventHandlerMock.queueEmptyCount, 0); | ||
XCTAssertEqual(self.eventHandlerMock.accessTokenCount, 1); | ||
|
||
NSArray *myArray = @[@0]; | ||
XCTAssertEqualObjects(self.eventHandlerMock.indecies, myArray); | ||
} | ||
|
||
- (void)testGetTokenEmptyQueue { | ||
[self.tokenStorage createTokens:@[]]; | ||
|
||
XCTAssertEqual([self.tokenStorage getToken], nil); | ||
XCTAssertEqual(self.eventHandlerMock.queueEmptyCount, 1); | ||
XCTAssertEqual(self.eventHandlerMock.accessTokenCount, 0); | ||
} | ||
|
||
- (void)testGetTokenAccessTokenInPeekMode { | ||
[self.tokenStorage setPeekMode:YES]; | ||
|
||
[self.tokenStorage createTokens:@[@"token1", @"token2"]]; | ||
|
||
XCTAssertEqual([self.tokenStorage getToken], @"token1"); | ||
XCTAssertEqual([self.tokenStorage getToken], @"token1"); | ||
XCTAssertEqual(self.eventHandlerMock.queueEmptyCount, 0); | ||
XCTAssertEqual(self.eventHandlerMock.accessTokenCount, 2); | ||
|
||
NSArray *myArray = @[@0, @1]; | ||
XCTAssertEqualObjects(self.eventHandlerMock.indecies, myArray); | ||
} | ||
|
||
@end |
Oops, something went wrong.