Added tests for placeholder mapping

This commit is contained in:
michael starke
2013-08-15 02:11:11 +02:00
parent fc7aa100b9
commit 16f10942ee
4 changed files with 53 additions and 1 deletions

View 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

View 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