From 8baab51469e6fe1ea62ce9203d8ef2fe643879d7 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Fri, 13 Nov 2009 23:35:07 +0000 Subject: Tidy up and fix unit tests. --- UnitTests/mcpKitTest.h | 6 ++-- UnitTests/mcpKitTest.m | 62 ++++++++++++++++----------------- UnitTests/stringCategoryAdditionsTest.h | 1 - UnitTests/stringCategoryAdditionsTest.m | 10 +++--- sequel-pro.xcodeproj/project.pbxproj | 35 +++++++++++-------- 5 files changed, 60 insertions(+), 54 deletions(-) diff --git a/UnitTests/mcpKitTest.h b/UnitTests/mcpKitTest.h index 8e5fd508..14f263bd 100644 --- a/UnitTests/mcpKitTest.h +++ b/UnitTests/mcpKitTest.h @@ -20,14 +20,14 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // More info at -// #import -#import + +@class MCPConnection; @interface mcpKitTest : SenTestCase { - MCPConnection *mySQLConnection; + MCPConnection *connection; } @end diff --git a/UnitTests/mcpKitTest.m b/UnitTests/mcpKitTest.m index 8af68c64..49c02eb8 100644 --- a/UnitTests/mcpKitTest.m +++ b/UnitTests/mcpKitTest.m @@ -20,7 +20,8 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // More info at -// + +#import #import "mcpKitTest.h" @@ -28,58 +29,55 @@ - (void)setUp { - // for now, we try an find the following database in the local connection - // if the connection fails for any reasons, tests are not run. + // For now, we try an find the following database in the local connection. + // If the connection fails for any reasons, tests are not run. // http://downloads.mysql.com/docs/sakila-db.zip - // set up a user called 'sakila' with no password that has all privs on the - // database 'sakila' + // + // Set up a user called 'sakila' with no password that has all privs on the + // database 'sakila'. + + connection = [[MCPConnection alloc] initToSocket:@"/var/mysql/mysql.sock" withLogin:@"sakila"]; - mySQLConnection = [[MCPConnection alloc] initToSocket:@"/var/mysql/mysql.sock" - withLogin:@"sakila" - password:@""]; + // Set the 'sakila' user's password + [connection setPassword:@""]; - if ( ![mySQLConnection isConnected] ) { - [mySQLConnection dealloc]; - mySQLConnection = nil; - STFail(@"unable to connect with server. No tests run!"); - } else { - if ( ! [mySQLConnection selectDB:@"sakila"]) { - [mySQLConnection dealloc]; - mySQLConnection = nil; - STFail(@"unable to use `sakila` database. No tests run!"); + if (![connection isConnected]) { + [connection dealloc]; + connection = nil; + STFail(@"Error connecting to database server. No tests were run."); + } + else { + if (![connection selectDB:@"sakila"]) { + [connection dealloc]; + connection = nil; + STFail(@"Error selecting database 'sakila'. No tests were run."); } } } - (void)tearDown { - if( mySQLConnection != nil ) { - [mySQLConnection disconnect]; - [mySQLConnection dealloc]; + if (connection != nil) { + [connection disconnect]; + [connection dealloc]; } } - (void)testServerVersion { - if( mySQLConnection == nil ) - return; + if (connection == nil) return; - STAssertTrue( [mySQLConnection serverMajorVersion] != 0, @"server version"); - STAssertTrue( [mySQLConnection serverMajorVersion] != 0, @"server version"); + STAssertTrue([connection serverMajorVersion] != 0, @"server version"); + STAssertTrue([connection serverMajorVersion] != 0, @"server version"); } - - (void)testTableList { - if( mySQLConnection == nil ) - return; - - MCPResult *theResult; + if (connection == nil) return; - NSString *pQuery = @"SELECT * FROM actor"; - theResult = [mySQLConnection queryString:pQuery]; + MCPResult *queryResult = [connection queryString:@"SELECT * FROM actor"]; - STAssertEquals([theResult numOfRows],(my_ulonglong)200, @"actors table count" ); + STAssertEquals([queryResult numOfRows], (my_ulonglong)200, @"actors table count"); } @end diff --git a/UnitTests/stringCategoryAdditionsTest.h b/UnitTests/stringCategoryAdditionsTest.h index 2fc611be..d995a29e 100644 --- a/UnitTests/stringCategoryAdditionsTest.h +++ b/UnitTests/stringCategoryAdditionsTest.h @@ -20,7 +20,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // More info at -// #import diff --git a/UnitTests/stringCategoryAdditionsTest.m b/UnitTests/stringCategoryAdditionsTest.m index cff13ac9..11a4a49b 100644 --- a/UnitTests/stringCategoryAdditionsTest.m +++ b/UnitTests/stringCategoryAdditionsTest.m @@ -20,7 +20,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // More info at -// #import "stringCategoryAdditionsTest.h" #import "SPStringAdditions.h" @@ -40,14 +39,17 @@ - (void)testStringByRemovingCharactersInSet { NSCharacterSet *junk = [NSCharacterSet characterSetWithCharactersInString:@"abc',ü"]; + NSString *s = @"this is big, crazy st'ring"; NSString *expect = @"this is ig rzy string"; - STAssertEqualObjects( [s stringByRemovingCharactersInSet:junk], expect, @"stringByRemovingCharactersInSet" ); - // check UTF + STAssertEqualObjects([s stringByRemovingCharactersInSet:junk], expect, @"stringByRemovingCharactersInSet"); + + // Check UTF s = @"In der Kürze liegt die Würz"; expect = @"In der Krze liegt die Wrz"; - STAssertEqualObjects( [s stringByRemovingCharactersInSet:junk], expect, @"stringByRemovingCharactersInSet" ); + + STAssertEqualObjects([s stringByRemovingCharactersInSet:junk], expect, @"stringByRemovingCharactersInSet"); } @end diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 5a40dc65..71c4a481 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -253,19 +253,19 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 17B7B59A1016039200F057DE /* PBXContainerItemProxy */ = { + 1792C2CC10AE239D00ABE758 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 2A37F4A9FDCFA73011CA2CEA /* Project object */; proxyType = 1; - remoteGlobalIDString = 17B7B5611016012700F057DE; + remoteGlobalIDString = 17B7B5611016012700F057DE /* MCPKit */; remoteInfo = MCPKit; }; - 380F4EDF0FC0B51D00B0BFD7 /* PBXContainerItemProxy */ = { + 17B7B59A1016039200F057DE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 2A37F4A9FDCFA73011CA2CEA /* Project object */; proxyType = 1; - remoteGlobalIDString = 8D15AC270486D014006FF6A4; - remoteInfo = "Sequel Pro"; + remoteGlobalIDString = 17B7B5611016012700F057DE; + remoteInfo = MCPKit; }; 58CDB34A0FCE144000F8ACA3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; @@ -1351,10 +1351,10 @@ 380F4EF20FC0B67A00B0BFD7 /* UnitTests */ = { isa = PBXGroup; children = ( - 380F4EF30FC0B68F00B0BFD7 /* stringCategoryAdditionsTest.h */, - 380F4EF40FC0B68F00B0BFD7 /* stringCategoryAdditionsTest.m */, 380F4F230FC0C3D300B0BFD7 /* mcpKitTest.h */, 380F4F240FC0C3D300B0BFD7 /* mcpKitTest.m */, + 380F4EF30FC0B68F00B0BFD7 /* stringCategoryAdditionsTest.h */, + 380F4EF40FC0B68F00B0BFD7 /* stringCategoryAdditionsTest.m */, ); path = UnitTests; sourceTree = ""; @@ -1484,7 +1484,7 @@ buildRules = ( ); dependencies = ( - 380F4EE00FC0B51D00B0BFD7 /* PBXTargetDependency */, + 1792C2CD10AE239D00ABE758 /* PBXTargetDependency */, ); name = "Unit Tests"; productName = "Unit Tests"; @@ -1847,15 +1847,15 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 17B7B59B1016039200F057DE /* PBXTargetDependency */ = { + 1792C2CD10AE239D00ABE758 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 17B7B5611016012700F057DE /* MCPKit */; - targetProxy = 17B7B59A1016039200F057DE /* PBXContainerItemProxy */; + targetProxy = 1792C2CC10AE239D00ABE758 /* PBXContainerItemProxy */; }; - 380F4EE00FC0B51D00B0BFD7 /* PBXTargetDependency */ = { + 17B7B59B1016039200F057DE /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = 8D15AC270486D014006FF6A4 /* Sequel Pro */; - targetProxy = 380F4EDF0FC0B51D00B0BFD7 /* PBXContainerItemProxy */; + target = 17B7B5611016012700F057DE /* MCPKit */; + targetProxy = 17B7B59A1016039200F057DE /* PBXContainerItemProxy */; }; 58CDB34B0FCE144000F8ACA3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; @@ -2061,7 +2061,8 @@ BCB56194106F893700167321 /* English */, ); name = ContentFilters.plist; - sourceTree = ""; + path = "/Users/stuart/Documents/Projects/SequelPro/sequel-pro/Resources"; + sourceTree = ""; }; BCB5619A106F8A1B00167321 /* EditorQuickLookTypes.plist */ = { isa = PBXVariantGroup; @@ -2196,6 +2197,8 @@ Cocoa, "-framework", SenTestingKit, + "-framework", + MCPKit, ); PREBINDING = NO; PRODUCT_NAME = "Unit Tests"; @@ -2226,6 +2229,8 @@ Cocoa, "-framework", SenTestingKit, + "-framework", + MCPKit, ); PREBINDING = NO; PRODUCT_NAME = "Unit Tests"; @@ -2254,6 +2259,8 @@ Cocoa, "-framework", SenTestingKit, + "-framework", + MCPKit, ); PREBINDING = NO; PRODUCT_NAME = "Unit Tests"; -- cgit v1.2.3