pEpObjCTests/PEPPassphraseCacheTest.m
branchIOSAD-172
changeset 1455 1b007f0523d3
parent 1453 2da4a0ba6b07
child 1458 8e31ce01a795
     1.1 --- a/pEpObjCTests/PEPPassphraseCacheTest.m	Thu Jun 25 17:08:21 2020 +0200
     1.2 +++ b/pEpObjCTests/PEPPassphraseCacheTest.m	Thu Jun 25 17:08:21 2020 +0200
     1.3 @@ -51,4 +51,37 @@
     1.4      XCTAssertEqualObjects(self.cache.passphrases, expected);
     1.5  }
     1.6  
     1.7 +- (void)testTwentyPassphrases
     1.8 +{
     1.9 +    NSMutableArray *passphrases = [NSMutableArray arrayWithCapacity:20];
    1.10 +    for (NSUInteger i = 0; i < 20; ++i) {
    1.11 +        NSString *newPhrase = [NSString stringWithFormat:@"passphrase_%lu", (unsigned long) i];
    1.12 +        [passphrases addObject:newPhrase];
    1.13 +        [self.cache addPassphrase:newPhrase];
    1.14 +    }
    1.15 +
    1.16 +    XCTAssertEqual(self.cache.passphrases.count, passphrases.count + 1);
    1.17 +    NSMutableArray *expected = [NSMutableArray arrayWithArray:passphrases];
    1.18 +    [expected insertObject:@"" atIndex:0];
    1.19 +    XCTAssertEqualObjects(self.cache.passphrases, expected);
    1.20 +}
    1.21 +
    1.22 +- (void)testTwentyOnePassphrases
    1.23 +{
    1.24 +    NSMutableArray *passphrases = [NSMutableArray arrayWithCapacity:20];
    1.25 +    for (NSUInteger i = 0; i < 20; ++i) {
    1.26 +        NSString *newPhrase = [NSString stringWithFormat:@"passphrase_%lu", (unsigned long) i];
    1.27 +        [passphrases addObject:newPhrase];
    1.28 +        [self.cache addPassphrase:newPhrase];
    1.29 +    }
    1.30 +
    1.31 +    NSString *latestPassphrase = @"theLatest";
    1.32 +    [passphrases replaceObjectAtIndex:0 withObject:latestPassphrase];
    1.33 +
    1.34 +    XCTAssertEqual(self.cache.passphrases.count, passphrases.count + 1);
    1.35 +    NSMutableArray *expected = [NSMutableArray arrayWithArray:passphrases];
    1.36 +    [expected insertObject:@"" atIndex:0];
    1.37 +    XCTAssertEqualObjects(self.cache.passphrases, expected);
    1.38 +}
    1.39 +
    1.40  @end