Skip to content

Commit

Permalink
Added Unit Test Case
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiDixit09 committed Oct 3, 2024
1 parent c2082f9 commit 5988a60
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Branch-TestBed/Branch-SDK-Tests/BNCServerRequestQueueTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,37 @@ - (void)testMultipleRequests {
XCTAssert([NSFileManager.defaultManager fileExistsAtPath:[[BNCServerRequestQueue URLForQueueFile] path]] == NO);
}

- (void)testUUIDANDTimeStampPersistence {
BranchEventRequest *eventObject = [BranchEventRequest new];
BranchOpenRequest *openObject = [BranchOpenRequest new];
NSString *uuidFromEventObject = eventObject.requestUUID;
NSNumber *timeStampFromEventObject = eventObject.requestCreationTimeStamp;
NSString *uuidFromOpenObject = openObject.requestUUID;
NSNumber *timeStampFromOpenObject = openObject.requestCreationTimeStamp;

XCTAssertTrue(![uuidFromEventObject isEqualToString:uuidFromOpenObject]);

[_queue enqueue: eventObject];
[_queue enqueue: openObject];
[_queue persistImmediately];

NSMutableArray *decodedQueue = nil;
NSData *data = [NSData dataWithContentsOfURL:[BNCServerRequestQueue URLForQueueFile] options:0 error:nil];
if (data) {
decodedQueue = [_queue unarchiveQueueFromData:data];
}

for (id requestObject in decodedQueue) {
if ([requestObject isKindOfClass:BranchEventRequest.class]) {
XCTAssertTrue([uuidFromEventObject isEqualToString:[(BranchEventRequest *)requestObject requestUUID]]);
XCTAssertTrue([timeStampFromEventObject isEqualToNumber:[(BranchEventRequest *)requestObject requestCreationTimeStamp]]);
}
if ([requestObject isKindOfClass:BranchOpenRequest.class]) {

XCTAssertTrue([uuidFromOpenObject isEqualToString:[(BranchOpenRequest *)requestObject requestUUID]]);
XCTAssertTrue([timeStampFromOpenObject isEqualToNumber:[(BranchOpenRequest *)requestObject requestCreationTimeStamp]]);
}
}
}

@end

0 comments on commit 5988a60

Please sign in to comment.