Migrated project to XCTest

This commit is contained in:
michael starke
2014-02-15 18:35:56 +01:00
parent edd2d89d30
commit 1f1c6d5dcb
22 changed files with 228 additions and 359 deletions

View File

@@ -6,7 +6,8 @@
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "KPKTestLegacyLoading.h"
#import <XCTest/XCTest.h>
#import "KPKTree+Serializing.h"
#import "KPKCompositeKey.h"
@@ -15,13 +16,17 @@
#import "KPKErrors.h"
@interface KPKTestLegacyLoading : XCTestCase
@end
@implementation KPKTestLegacyLoading
- (void)testValidFile {
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
NSData *data = [self _loadTestDataBase:@"Test_Password_1234" extension:@"kdb"];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:NULL];
STAssertNotNil(tree, @"Loading should result in a tree object");
XCTAssertNotNil(tree, @"Loading should result in a tree object");
}
- (void)testWrongPassword {
@@ -29,8 +34,8 @@
NSData *data = [self _loadTestDataBase:@"KeePass1_native_test" extension:@"kdb"];
NSError *error;
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:&error];
STAssertNil(tree, @"Wrong password should yield nil tree");
STAssertNotNil(error, @"Wrong password should yield error");
XCTAssertNil(tree, @"Wrong password should yield nil tree");
XCTAssertNotNil(error, @"Wrong password should yield error");
//STAssertTrue([error code] == KPKErrorPasswordAndOrKeyfileWrong, @"Error code should be wrong password and/or keyfile");
}
@@ -39,9 +44,9 @@
uint8_t bytes[] = {0x00,0x11,0x22,0x33,0x44};
NSData *data = [NSData dataWithBytes:bytes length:5];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:nil error:&error];
STAssertNil(tree, @"Tree should be nil with invalid data");
STAssertNotNil(error, @"Error object should have been created");
STAssertTrue(KPKErrorUnknownFileFormat == [error code], @"Error should be Unknown file format");
XCTAssertNil(tree, @"Tree should be nil with invalid data");
XCTAssertNotNil(error, @"Error object should have been created");
XCTAssertTrue(KPKErrorUnknownFileFormat == [error code], @"Error should be Unknown file format");
}
@@ -49,10 +54,10 @@
NSData *data = [self _loadTestDataBase:@"KDB1_KeePassX_test" extension:@"kdb"];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"test" key:nil];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:NULL];
STAssertNotNil(tree, @"Tree shoudl be loaded" );
XCTAssertNotNil(tree, @"Tree shoudl be loaded" );
KPKIcon *icon = [tree.metaData.customIcons lastObject];
STAssertNotNil(icon, @"Should load one Icon");
XCTAssertNotNil(icon, @"Should load one Icon");
}
- (NSData *)_loadTestDataBase:(NSString *)name extension:(NSString *)extension {