Skip to content

Commit

Permalink
tests update
Browse files Browse the repository at this point in the history
  • Loading branch information
Valeriu Popa committed Nov 13, 2023
1 parent 8a8a09e commit 1a0e4ba
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 39 deletions.
13 changes: 8 additions & 5 deletions CriteoPublisherSdk/Tests/UnitTests/CR_CdbBidTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#import "CR_CdbResponse.h"
#import "NSDictionary+Criteo.h"
#import "NSString+CriteoUrl.h"
#import "CR_SKAdNetworkFidelityParameter.h"

@interface CR_CdbBidTests : XCTestCase

Expand Down Expand Up @@ -190,12 +191,14 @@ - (void)testInitialization {
XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.networkId, @"network");
XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.campaignId, @1);
XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.iTunesItemId, @2);
XCTAssertEqualObjects(
nativeBid.skAdNetworkParameters.nonce,
[[NSUUID alloc] initWithUUIDString:@"ef50fece-faf4-4a5c-91b4-37e90b71a829"]);
XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.sourceAppId, @3);
XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.timestamp, @4);
XCTAssertEqualObjects(nativeBid.skAdNetworkParameters.signature, @"signature");

CR_SKAdNetworkFidelityParameter *fidelity =
nativeBid.skAdNetworkParameters.fidelities.firstObject;
XCTAssertEqualObjects(fidelity.timestamp, @4);
XCTAssertEqualObjects(fidelity.signature, @"signature");
XCTAssertEqualObjects(
fidelity.nonce, [[NSUUID alloc] initWithUUIDString:@"ef50fece-faf4-4a5c-91b4-37e90b71a829"]);
}

- (void)testEmptyInitialization {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ - (void)testImpression {
version:version
campaignId:campaignId
iTunesItemId:iTunesItemId
nonce:nonce
timestamp:timestamp
sourceAppId:sourceAppId
signature:signature
fidelities:[NSArray arrayWithObject:fidelity]];
CR_SKAdNetworkHandler *handler =
[[CR_SKAdNetworkHandler alloc] initWithParameters:skAdNetworkParameters];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ - (void)testInitWithDict_GivenExpectedTypes_ReturnParameters {
XCTAssertEqualObjects(parameters.networkId, networkId);
XCTAssertEqualObjects(parameters.campaignId, campaignId);
XCTAssertEqualObjects(parameters.iTunesItemId, iTunesItemId);
XCTAssertEqualObjects(parameters.nonce, nonce);
XCTAssertEqualObjects(parameters.sourceAppId, sourceAppId);
XCTAssertEqualObjects(parameters.timestamp, timestamp);
XCTAssertEqualObjects(parameters.signature, signature);
XCTAssertTrue(parameters.fidelities.count == 0);
}

Expand Down Expand Up @@ -93,10 +90,7 @@ - (void)testInitWithDict_GivenAlternateValidTypes_ReturnParameters {
XCTAssertEqualObjects(parameters.networkId, networkId);
XCTAssertEqualObjects(parameters.campaignId, campaignId);
XCTAssertEqualObjects(parameters.iTunesItemId, iTunesItemId);
XCTAssertEqualObjects(parameters.nonce, nonce);
XCTAssertEqualObjects(parameters.sourceAppId, sourceAppId);
XCTAssertEqualObjects(parameters.timestamp, timestamp);
XCTAssertEqualObjects(parameters.signature, signature);
}

- (void)testInitWithDict_GivenNil_ReturnNil {
Expand Down Expand Up @@ -128,16 +122,18 @@ - (void)testToLoadProductParameters API_AVAILABLE(ios(14.0)) {
NSNumber *timestamp = @(123457890);
NSNumber *sourceAppId = @(87654321);
NSString *signature = @"signature";
CR_SKAdNetworkFidelityParameter *fidelityParam =
[[CR_SKAdNetworkFidelityParameter alloc] initWithFidelity:@1
timestamp:timestamp
nonce:nonce
signature:signature];
CR_SKAdNetworkParameters *skAdNetworkParameters =
[[CR_SKAdNetworkParameters alloc] initWithNetworkId:networkId
version:version
campaignId:campaignId
iTunesItemId:iTunesItemId
nonce:nonce
timestamp:timestamp
sourceAppId:sourceAppId
signature:signature
fidelities:[NSArray new]];
fidelities:[NSArray arrayWithObject:fidelityParam]];
NSDictionary *loadProductParameters = skAdNetworkParameters.toLoadProductParameters;
NSDictionary *expected = @{
SKStoreProductParameterAdNetworkVersion : version,
Expand All @@ -155,21 +151,15 @@ - (void)testToLoadProductParameters API_AVAILABLE(ios(14.0)) {
- (void)testInitWithDict_GivenEmptyFidelities {
NSString *networkId = @"networkId";
NSString *version = @"2.0";
NSUUID *nonce = [NSUUID UUID];
NSNumber *campaignId = @(42);
NSNumber *iTunesItemId = @(12345678);
NSNumber *timestamp = @(123457890);
NSNumber *sourceAppId = @(87654321);
NSString *signature = @"signature";
CR_SKAdNetworkParameters *skAdNetworkParameters =
[[CR_SKAdNetworkParameters alloc] initWithNetworkId:networkId
version:version
campaignId:campaignId
iTunesItemId:iTunesItemId
nonce:nonce
timestamp:timestamp
sourceAppId:sourceAppId
signature:signature
fidelities:[NSArray new]];
XCTAssertTrue(skAdNetworkParameters.fidelities.count == 0);
}
Expand Down
11 changes: 8 additions & 3 deletions CriteoPublisherSdk/Tests/UnitTests/SampleBid.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@
"network" : "network",
"campaign" : "1",
"itunesItem" : "2",
"nonce" : "ef50fece-faf4-4a5c-91b4-37e90b71a829",
"sourceApp" : "3",
"timestamp" : "4",
"signature" : "signature"
"fidelities": [
{
"fidelity": "1",
"timestamp" : "4",
"signature" : "signature",
"nonce" : "ef50fece-faf4-4a5c-91b4-37e90b71a829"
}
]
}
},
{
Expand Down
22 changes: 13 additions & 9 deletions CriteoPublisherSdk/Tests/UnitTests/Util/CR_URLOpenerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#import "CR_URLOpener.h"
#import "CR_SKAdNetworkParameters.h"
#import "CR_SKAdNetworkFidelityParameter.h"

@interface CR_URLOpenerTests : XCTestCase
@end
Expand Down Expand Up @@ -65,15 +66,18 @@ - (void)testOpenAppStoreURLWithoutSKAdNetworkParameters {
}

- (CR_SKAdNetworkParameters *)buildParameters {
return [[CR_SKAdNetworkParameters alloc] initWithNetworkId:@"networkId"
version:@"2.0"
campaignId:@1
iTunesItemId:@12345
nonce:[NSUUID UUID]
timestamp:@123567890
sourceAppId:@67890
signature:@"tlkjlkj"
fidelities:[NSArray new]];
CR_SKAdNetworkFidelityParameter *fidelityParam =
[[CR_SKAdNetworkFidelityParameter alloc] initWithFidelity:@1
timestamp:@123567890
nonce:[NSUUID UUID]
signature:@"tlkjlkj"];
return
[[CR_SKAdNetworkParameters alloc] initWithNetworkId:@"networkId"
version:@"2.0"
campaignId:@1
iTunesItemId:@12345
sourceAppId:@67890
fidelities:[NSArray arrayWithObject:fidelityParam]];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ - (void)injectBidWithExpectedCreativeUrl:(NSString *)creativeUrl
version:@"2.0"
campaignId:@1
iTunesItemId:@2
nonce:[NSUUID UUID]
timestamp:@3
sourceAppId:@4
signature:@"signature"
fidelities:[NSArray new]]);
}
CR_CdbBid *bid = bidBuilder.build;
Expand Down

0 comments on commit 1a0e4ba

Please sign in to comment.