mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 01:12:31 +00:00
Added tests for placeholder mapping
This commit is contained in:
13
MacPassTests/KPKTextPlaceholder.h
Normal file
13
MacPassTests/KPKTextPlaceholder.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// KPKTextPlaceholder.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 15.08.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <SenTestingKit/SenTestingKit.h>
|
||||
|
||||
@interface KPKTextPlaceholder : SenTestCase
|
||||
|
||||
@end
|
||||
33
MacPassTests/KPKTextPlaceholder.m
Normal file
33
MacPassTests/KPKTextPlaceholder.m
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// KPKTextPlaceholder.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 15.08.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KPKTextPlaceholder.h"
|
||||
#import "KPKEntry.h"
|
||||
#import "KPKAttribute.h"
|
||||
|
||||
#import "NSString+CommandString.h"
|
||||
|
||||
@implementation KPKTextPlaceholder
|
||||
|
||||
- (void)testPlaceholder {
|
||||
KPKEntry *entry = [[KPKEntry alloc] init];
|
||||
entry.title = @"TestTitle";
|
||||
entry.username = @"TestUsername";
|
||||
entry.notes = @"TestNotes";
|
||||
entry.url = @"TestURL";
|
||||
entry.password = @"TestPassword";
|
||||
KPKAttribute *attribute = [[KPKAttribute alloc] initWithKey:@"extended" value:@"valueForExtended"];
|
||||
[entry addCustomAttribute:attribute];
|
||||
|
||||
NSString *placeholder = @"{USERNAME}{PASSWORD}{NOTHING}{URL}{S:extended}";
|
||||
NSString *evaluated = [placeholder evaluatePlaceholderWithEntry:entry];
|
||||
NSString *evaluatedGoal = [NSString stringWithFormat:@"%@%@{NOTHING}%@%@", entry.username, entry.password, entry.url, attribute.value];
|
||||
STAssertTrue([evaluated isEqualToString:evaluatedGoal], @"Evaluated string must match");
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user