Fixed issue with notes field not being properly bound to Group notes

This commit is contained in:
michael starke
2013-08-01 19:40:30 +02:00
parent 115537c95b
commit 560d9ce941
11 changed files with 354 additions and 116 deletions

View File

@@ -28,10 +28,6 @@
}
- (void)testEntryCoding {
/*
1. Deep Copy
2. Copy without History
*/
KPKEntry *entry = [[KPKEntry alloc] init];
entry.title = @"Title";

View File

@@ -7,7 +7,59 @@
//
#import "KPKTestNSCopying.h"
#import "KPKEntry.h"
#import "KPKAttribute.h"
#import "KPKBinary.h"
@implementation KPKTestNSCopying
- (void)testAttributeCopying {
KPKAttribute *attribute = [[KPKAttribute alloc] initWithKey:@"Key" value:@"Value" isProtected:NO];
KPKAttribute *copy = [attribute copy];
attribute.key = @"NewKey";
attribute.value = @"NewValue";
attribute.isProtected = YES;
STAssertNotNil(copy, @"Copy shoule exist");
STAssertTrue([copy.key isEqualToString:@"Key"], @"Copy key should be key");
STAssertTrue([copy.value isEqualToString:@"Value"], @"Copy value should be value");
STAssertFalse(copy.isProtected, @"Copy should not be protected");
}
- (void)testEntryCopying {
KPKEntry *entry = [[KPKEntry alloc] init];
entry.title = @"Title";
entry.url = @"URL";
entry.username = @"Username";
entry.password = @"Password";
uint8 bytes[] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF };
NSData *data = [[NSData alloc] initWithBytes:bytes length:5];
KPKBinary *binary = [[KPKBinary alloc] init];
binary.data = data;
binary.name = @"Binary";
[entry addBinary:binary];
[entry addCustomAttribute:[[KPKAttribute alloc] initWithKey:@"Custom" value:@"Value" isProtected:NO]];
KPKEntry *copyEntry = [entry copy];
entry.title = @"NewTitle";
[entry removeBinary:binary];
[[entry.customAttributes lastObject] setKey:@"NewCustomKey"];
STAssertNotNil(copyEntry, @"Copied Entry cannot be nil");
STAssertTrue([copyEntry.title isEqualToString:@"Title"], @"Titles should match");
STAssertTrue([copyEntry.url isEqualToString:@"URL"], @"URLS should match");
STAssertTrue([copyEntry.binaries count] == 1, @"Binareis should be copied");
KPKBinary *copiedBinary = [copyEntry.binaries lastObject];
STAssertTrue([copiedBinary.data isEqualToData:binary.data], @"Binary data should match");
STAssertTrue([copiedBinary.name isEqualToString:binary.name], @"Binary names should macht");
}
@end