pEpObjCTests/PEPPassphraseCacheTest.m
author Dirk Zimmermann <dz@pep.security>
Thu, 25 Jun 2020 17:08:21 +0200
branchIOSAD-172
changeset 1453 2da4a0ba6b07
parent 1450 02d7ef1f360b
child 1455 1b007f0523d3
permissions -rw-r--r--
IOSAD-172 Test for 2 passphrases
     1 //
     2 //  PEPPassphraseCacheTest.m
     3 //  pEpObjCAdapterTests
     4 //
     5 //  Created by Dirk Zimmermann on 25.06.20.
     6 //  Copyright © 2020 p≡p. All rights reserved.
     7 //
     8 
     9 #import <XCTest/XCTest.h>
    10 
    11 #import "PEPPassphraseCache.h"
    12 
    13 @interface PEPPassphraseCacheTest : XCTestCase
    14 
    15 @property (nonatomic) PEPPassphraseCache *cache;
    16 
    17 @end
    18 
    19 @implementation PEPPassphraseCacheTest
    20 
    21 - (void)setUp
    22 {
    23     self.cache = [[PEPPassphraseCache alloc] init];
    24 }
    25 
    26 - (void)testContainsEmptyPassphrase
    27 {
    28     XCTAssertEqual(self.cache.passphrases.count, 1);
    29     XCTAssertEqualObjects(self.cache.passphrases, @[@""]);
    30 }
    31 
    32 - (void)testContainsSetPassphrase
    33 {
    34     NSString *passphrase = @"somepass";
    35     [self.cache addPassphrase:passphrase];
    36     XCTAssertEqual(self.cache.passphrases.count, 2);
    37     NSArray *expected = @[@"", passphrase];
    38     XCTAssertEqualObjects(self.cache.passphrases, expected);
    39 }
    40 
    41 - (void)testContainsSetPassphrases
    42 {
    43     NSString *passphrase1 = @"somepass1";
    44     NSString *passphrase2 = @"somepass2";
    45 
    46     [self.cache addPassphrase:passphrase1];
    47     [self.cache addPassphrase:passphrase2];
    48 
    49     XCTAssertEqual(self.cache.passphrases.count, 3);
    50     NSArray *expected = @[@"", passphrase1, passphrase2];
    51     XCTAssertEqualObjects(self.cache.passphrases, expected);
    52 }
    53 
    54 @end