IOSAD-134 Test queries in a loop (ENGINE-604). IOSAD-134
authorDirk Zimmermann <dz@pep.security>
Mon, 02 Sep 2019 16:47:25 +0200
branchIOSAD-134
changeset 1199cb6e149386dd
parent 1198 ab5c05c35481
child 1200 78570b5c3dd4
IOSAD-134 Test queries in a loop (ENGINE-604).
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Mon Sep 02 16:47:25 2019 +0200
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Mon Sep 02 16:47:25 2019 +0200
     1.3 @@ -1371,6 +1371,37 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +- (void)testQueryKeySyncOnOwnIdentityInALoop
     1.8 +{
     1.9 +    PEPSession *session = [PEPSession new];
    1.10 +
    1.11 +    PEPIdentity *identMe = [[PEPIdentity alloc]
    1.12 +                            initWithAddress:@"me-myself-and-i@pep-project.org"
    1.13 +                            userID:@"me-myself-and-i"
    1.14 +                            userName:@"pEp Me"
    1.15 +                            isOwn:YES];
    1.16 +    NSError *error = nil;
    1.17 +    XCTAssertTrue([session mySelf:identMe error:&error]);
    1.18 +    XCTAssertNil(error);
    1.19 +
    1.20 +    for (NSNumber *numBool in @[@YES, @NO]) {
    1.21 +        error = nil;
    1.22 +        if ([numBool boolValue]) {
    1.23 +            XCTAssertTrue([session enableSyncForIdentity:identMe error:&error]);
    1.24 +        } else {
    1.25 +            XCTAssertTrue([session disableSyncForIdentity:identMe error:&error]);
    1.26 +        }
    1.27 +        XCTAssertNil(error);
    1.28 +
    1.29 +        for (int i = 0; i < 10; ++i) {
    1.30 +            NSNumber *numQuery = [session queryKeySyncEnabledForIdentity:identMe error:&error];
    1.31 +            XCTAssertNotNil(numQuery);
    1.32 +            XCTAssertEqualObjects(numBool, numQuery);
    1.33 +            XCTAssertNil(error);
    1.34 +        }
    1.35 +    }
    1.36 +}
    1.37 +
    1.38  #pragma mark - Helpers
    1.39  
    1.40  - (void)testSendMessageOnSession:(PEPSession *)session