From c9338aee82e9b42a07e93625c3235977c3dbf1b4 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Wed, 2 Feb 2011 23:10:06 +0000 Subject: Fix favorites sorting. --- UnitTests/SPMutableArrayAdditionsTest.h | 37 +++++++++++++++++++++++++++++ UnitTests/SPMutableArrayAdditionsTest.m | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 UnitTests/SPMutableArrayAdditionsTest.h create mode 100644 UnitTests/SPMutableArrayAdditionsTest.m (limited to 'UnitTests') diff --git a/UnitTests/SPMutableArrayAdditionsTest.h b/UnitTests/SPMutableArrayAdditionsTest.h new file mode 100644 index 00000000..a7665a27 --- /dev/null +++ b/UnitTests/SPMutableArrayAdditionsTest.h @@ -0,0 +1,37 @@ +// +// $Id$ +// +// SPMutableArrayAdditionsTest.h +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on February 2, 2011 +// Copyright (c) 2011 Stuart Connolly. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import + +/** + * @class SPMutableArrayAdditionsTest SPMutableArrayAdditionsTest.h + * + * @author Stuart Connolly http://stuconnolly.com/ + * + * SPMutableArrayAdditions tests class. + */ +@interface SPMutableArrayAdditionsTest : SenTestCase + +@end diff --git a/UnitTests/SPMutableArrayAdditionsTest.m b/UnitTests/SPMutableArrayAdditionsTest.m new file mode 100644 index 00000000..4f265b34 --- /dev/null +++ b/UnitTests/SPMutableArrayAdditionsTest.m @@ -0,0 +1,41 @@ +// +// $Id$ +// +// SPMutableArrayAdditionsTest.m +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on February 2, 2011 +// Copyright (c) 2011 Stuart Connolly. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import "SPMutableArrayAdditionsTest.h" +#import "SPMutableArrayAdditions.h" + +@implementation SPMutableArrayAdditionsTest + +- (void)testReverse +{ + NSMutableArray *testArray = [NSMutableArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", nil]; + NSMutableArray *expectedArray = [NSMutableArray arrayWithObjects:@"5", @"4", @"3", @"2", @"1", nil]; + + [testArray reverse]; + + STAssertEqualObjects(testArray, expectedArray, @"The reversed array should look like: %@", expectedArray); +} + +@end -- cgit v1.2.3 From 3ed8b33deeadcc98185911f41bc6bcb4e53b4719 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 3 Apr 2011 09:34:29 +0000 Subject: Bring outline view branch up to date with trunk (r3246:r3264). --- UnitTests/MCPKitTest.m | 8 +++--- UnitTests/SPDatabaseCopyTest.m | 6 ++-- UnitTests/SPDatabaseRenameTest.m | 2 +- UnitTests/SPMenuAdditionsTests.h | 33 ++++++++++++++++++++++ UnitTests/SPMenuAdditionsTests.m | 58 +++++++++++++++++++++++++++++++++++++++ UnitTests/SPStringAdditionsTest.m | 4 +-- 6 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 UnitTests/SPMenuAdditionsTests.h create mode 100644 UnitTests/SPMenuAdditionsTests.m (limited to 'UnitTests') diff --git a/UnitTests/MCPKitTest.m b/UnitTests/MCPKitTest.m index 4480b0a1..559a1407 100644 --- a/UnitTests/MCPKitTest.m +++ b/UnitTests/MCPKitTest.m @@ -27,10 +27,10 @@ #import "MCPKitTest.h" -static const NSString *SPTestDatabaseHost = @"127.0.0.1"; -static const NSString *SPTestDatabaseName = @"sakila"; -static const NSString *SPTestDatabaseUser = @"sp_tester"; -static const NSString *SPTestDatabasePassword = @""; +static NSString *SPTestDatabaseHost = @"127.0.0.1"; +static NSString *SPTestDatabaseName = @"sakila"; +static NSString *SPTestDatabaseUser = @"sp_tester"; +static NSString *SPTestDatabasePassword = @""; static const NSInteger SPTestDatabasePort = 3306; diff --git a/UnitTests/SPDatabaseCopyTest.m b/UnitTests/SPDatabaseCopyTest.m index a1ed99fe..9ba7d5b7 100644 --- a/UnitTests/SPDatabaseCopyTest.m +++ b/UnitTests/SPDatabaseCopyTest.m @@ -83,9 +83,9 @@ [target release]; } -- (void) testCreateDatabase { - SPDatabaseCopy *dbCopy = [self getDatabaseCopyFixture]; - // test missing :) +- (void)testCreateDatabase +{ + [self getDatabaseCopyFixture]; } @end diff --git a/UnitTests/SPDatabaseRenameTest.m b/UnitTests/SPDatabaseRenameTest.m index 1d432c73..9a1c7b1d 100644 --- a/UnitTests/SPDatabaseRenameTest.m +++ b/UnitTests/SPDatabaseRenameTest.m @@ -93,7 +93,7 @@ - (void)testCreateDatabase { - SPDatabaseRename *dbRename = [self getDatabaseRenameFixture]; + [self getDatabaseRenameFixture]; } @end diff --git a/UnitTests/SPMenuAdditionsTests.h b/UnitTests/SPMenuAdditionsTests.h new file mode 100644 index 00000000..1ff2ab61 --- /dev/null +++ b/UnitTests/SPMenuAdditionsTests.h @@ -0,0 +1,33 @@ +// +// $Id$ +// +// SPMenuAdditionsTests.h +// sequel-pro +// +// Created by Stuart Connolly on March 20, 2011 +// Copyright (c) 2011 Stuart Connolly. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import + +@interface SPMenuAdditionsTests : SenTestCase +{ + NSMenu *menu; +} + +@end diff --git a/UnitTests/SPMenuAdditionsTests.m b/UnitTests/SPMenuAdditionsTests.m new file mode 100644 index 00000000..15130df2 --- /dev/null +++ b/UnitTests/SPMenuAdditionsTests.m @@ -0,0 +1,58 @@ +// +// $Id$ +// +// SPMenuAdditionsTests.m +// sequel-pro +// +// Created by Stuart Connolly on March 20, 2011 +// Copyright (c) 2011 Stuart Connolly. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import "SPMenuAdditionsTests.h" +#import "SPMenuAdditions.h" + +static NSString *SPTestMenuItemTitle = @"Menu Item"; + +@implementation SPMenuAdditionsTests + +- (void)setUp +{ + NSUInteger num = 5; + + menu = [[NSMenu alloc] init]; + + for (NSUInteger i = 0; i < num; i++) + { + [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %d", SPTestMenuItemTitle, i] action:NULL keyEquivalent:@""]; + } +} + +- (void)tearDown +{ + [menu release], menu = nil; +} + +- (void)testCompatibleRemoveAllItems +{ + [menu compatibleRemoveAllItems]; + + STAssertFalse([menu numberOfItems], @"The menu should have no menu items."); +} + +@end + diff --git a/UnitTests/SPStringAdditionsTest.m b/UnitTests/SPStringAdditionsTest.m index 8fce7e07..b0143a0f 100644 --- a/UnitTests/SPStringAdditionsTest.m +++ b/UnitTests/SPStringAdditionsTest.m @@ -26,8 +26,8 @@ #import "SPStringAdditionsTest.h" #import "SPStringAdditions.h" -static const NSString *SPASCIITestString = @"this is a big, crazy test st'ring with som'e random spaces and quot'es"; -static const NSString *SPUTFTestString = @"In der Kürze liegt die Würz"; +static NSString *SPASCIITestString = @"this is a big, crazy test st'ring with som'e random spaces and quot'es"; +static NSString *SPUTFTestString = @"In der Kürze liegt die Würz"; @implementation SPStringAdditionsTest -- cgit v1.2.3 From 1d7ed99d602bf9c7aa4ea40a9a2ab6458864e51f Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 22 Jan 2012 12:19:21 +0000 Subject: Bring outlinew view branch up to date with trunk (r3375:3468). --- UnitTests/QKSelectQueryTests.h | 35 +++++++++++++++++++ UnitTests/QKSelectQueryTests.m | 76 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 UnitTests/QKSelectQueryTests.h create mode 100644 UnitTests/QKSelectQueryTests.m (limited to 'UnitTests') diff --git a/UnitTests/QKSelectQueryTests.h b/UnitTests/QKSelectQueryTests.h new file mode 100644 index 00000000..5a7bdafc --- /dev/null +++ b/UnitTests/QKSelectQueryTests.h @@ -0,0 +1,35 @@ +// +// $Id$ +// +// QKSelectQueryTests.h +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on September 4, 2011 +// Copyright (c) 2011 Stuart Connolly. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import + +#import + +@interface QKSelectQueryTests : SenTestCase +{ + QKQuery *_query; +} + +@end diff --git a/UnitTests/QKSelectQueryTests.m b/UnitTests/QKSelectQueryTests.m new file mode 100644 index 00000000..84b4584c --- /dev/null +++ b/UnitTests/QKSelectQueryTests.m @@ -0,0 +1,76 @@ +// +// $Id$ +// +// QKSelectQueryTests.m +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on September 4, 2011 +// Copyright (c) 2011 Stuart Connolly. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import "QKSelectQueryTests.h" + +static NSString *QKTestTableName = @"test_table"; + +static NSString *QKTestFieldOne = @"test_field1"; +static NSString *QKTestFieldTwo = @"test_field2"; +static NSString *QKTestFieldThree = @"test_field3"; +static NSString *QKTestFieldFour = @"test_field4"; + +static NSUInteger QKTestParameterOne = 10; + +@implementation QKSelectQueryTests + +#pragma mark - +#pragma mark Setup & tear down + +- (void)setUp +{ + _query = [QKQuery selectQueryFromTable:QKTestTableName]; + + [_query addField:QKTestFieldOne]; + [_query addField:QKTestFieldTwo]; + [_query addField:QKTestFieldThree]; + [_query addField:QKTestFieldFour]; + + [_query addParameter:QKTestFieldOne operator:QKEqualityOperator value:[NSNumber numberWithUnsignedInteger:QKTestParameterOne]]; +} + +#pragma mark - +#pragma mark Tests + +- (void)testSelectQueryTypeIsCorrect +{ + STAssertTrue([[_query query] hasPrefix:@"SELECT"], @"query type"); +} + +- (void)testSelectQueryFieldsAreCorrect +{ + NSString *query = [NSString stringWithFormat:@"SELECT %@, %@, %@, %@", QKTestFieldOne, QKTestFieldTwo, QKTestFieldThree, QKTestFieldFour]; + + STAssertTrue([[_query query] hasPrefix:query], @"query fields"); +} + +- (void)testSelectQueryConstraintsAreCorrect +{ + NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]]; + + STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"query constraints"); +} + +@end -- cgit v1.2.3 From 524e8c356b4074f5be5933b0551374a130a8f6d1 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 18 Mar 2012 20:05:36 +0000 Subject: Bring outline view branch up to date with trunk (r3471:r3517). --- UnitTests/QKSelectQueryTests.h | 35 ------------------- UnitTests/QKSelectQueryTests.m | 76 ------------------------------------------ 2 files changed, 111 deletions(-) delete mode 100644 UnitTests/QKSelectQueryTests.h delete mode 100644 UnitTests/QKSelectQueryTests.m (limited to 'UnitTests') diff --git a/UnitTests/QKSelectQueryTests.h b/UnitTests/QKSelectQueryTests.h deleted file mode 100644 index 5a7bdafc..00000000 --- a/UnitTests/QKSelectQueryTests.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// $Id$ -// -// QKSelectQueryTests.h -// sequel-pro -// -// Created by Stuart Connolly (stuconnolly.com) on September 4, 2011 -// Copyright (c) 2011 Stuart Connolly. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at - -#import - -#import - -@interface QKSelectQueryTests : SenTestCase -{ - QKQuery *_query; -} - -@end diff --git a/UnitTests/QKSelectQueryTests.m b/UnitTests/QKSelectQueryTests.m deleted file mode 100644 index 84b4584c..00000000 --- a/UnitTests/QKSelectQueryTests.m +++ /dev/null @@ -1,76 +0,0 @@ -// -// $Id$ -// -// QKSelectQueryTests.m -// sequel-pro -// -// Created by Stuart Connolly (stuconnolly.com) on September 4, 2011 -// Copyright (c) 2011 Stuart Connolly. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at - -#import "QKSelectQueryTests.h" - -static NSString *QKTestTableName = @"test_table"; - -static NSString *QKTestFieldOne = @"test_field1"; -static NSString *QKTestFieldTwo = @"test_field2"; -static NSString *QKTestFieldThree = @"test_field3"; -static NSString *QKTestFieldFour = @"test_field4"; - -static NSUInteger QKTestParameterOne = 10; - -@implementation QKSelectQueryTests - -#pragma mark - -#pragma mark Setup & tear down - -- (void)setUp -{ - _query = [QKQuery selectQueryFromTable:QKTestTableName]; - - [_query addField:QKTestFieldOne]; - [_query addField:QKTestFieldTwo]; - [_query addField:QKTestFieldThree]; - [_query addField:QKTestFieldFour]; - - [_query addParameter:QKTestFieldOne operator:QKEqualityOperator value:[NSNumber numberWithUnsignedInteger:QKTestParameterOne]]; -} - -#pragma mark - -#pragma mark Tests - -- (void)testSelectQueryTypeIsCorrect -{ - STAssertTrue([[_query query] hasPrefix:@"SELECT"], @"query type"); -} - -- (void)testSelectQueryFieldsAreCorrect -{ - NSString *query = [NSString stringWithFormat:@"SELECT %@, %@, %@, %@", QKTestFieldOne, QKTestFieldTwo, QKTestFieldThree, QKTestFieldFour]; - - STAssertTrue([[_query query] hasPrefix:query], @"query fields"); -} - -- (void)testSelectQueryConstraintsAreCorrect -{ - NSString *query = [NSString stringWithFormat:@"WHERE %@ %@ %@", QKTestFieldOne, [QKQueryUtilities operatorRepresentationForType:QKEqualityOperator], [NSNumber numberWithUnsignedInteger:QKTestParameterOne]]; - - STAssertTrue(([[_query query] rangeOfString:query].location != NSNotFound), @"query constraints"); -} - -@end -- cgit v1.2.3 From 4cad6f0e6e4fb497b480256c2abe3de34ebf225c Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Mon, 16 Apr 2012 20:16:52 +0000 Subject: Bring outline view branch up to date with trunk. --- UnitTests/MCPKitTest.h | 46 ------------------ UnitTests/MCPKitTest.m | 123 ------------------------------------------------- 2 files changed, 169 deletions(-) delete mode 100644 UnitTests/MCPKitTest.h delete mode 100644 UnitTests/MCPKitTest.m (limited to 'UnitTests') diff --git a/UnitTests/MCPKitTest.h b/UnitTests/MCPKitTest.h deleted file mode 100644 index 926780fa..00000000 --- a/UnitTests/MCPKitTest.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// $Id$ -// -// MCPKitTest.h -// sequel-pro -// -// Created by J Knight on 17/05/09. -// Copyright 2009 J Knight. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at - -#import - -@class MCPConnection; - -/** - * @class MCPKitTest MCPKitTest.h - * - * MCPKit test case class. - * - * Note that this test case class uses the 'sakila' database to perform it's tests. It is available from: - * - * http://downloads.mysql.com/docs/sakila-db.zip - * - * You must also create a user called 'sp_tester' with no password and all permissions on the database 'sakila'. - */ -@interface MCPKitTest : SenTestCase -{ - MCPConnection *connection; -} - -@end diff --git a/UnitTests/MCPKitTest.m b/UnitTests/MCPKitTest.m deleted file mode 100644 index 559a1407..00000000 --- a/UnitTests/MCPKitTest.m +++ /dev/null @@ -1,123 +0,0 @@ -// -// $Id$ -// -// MCPKitTest.m -// sequel-pro -// -// Created by J Knight on 17/05/09. -// Copyright 2009 J Knight. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at - -#import - -#import "MCPKitTest.h" - -static NSString *SPTestDatabaseHost = @"127.0.0.1"; -static NSString *SPTestDatabaseName = @"sakila"; -static NSString *SPTestDatabaseUser = @"sp_tester"; -static NSString *SPTestDatabasePassword = @""; - -static const NSInteger SPTestDatabasePort = 3306; - -@implementation MCPKitTest - -#pragma mark - -#pragma mark Setup & tear down - -/** - * Sets up the connection for use in the test cases. - */ -- (void)setUp -{ - connection = [[MCPConnection alloc] initToHost:SPTestDatabaseHost withLogin:SPTestDatabaseUser usingPort:SPTestDatabasePort]; - - [connection setPassword:SPTestDatabasePassword]; - - [connection setConnectionTimeout:10]; - [connection setUseKeepAlive:1]; - [connection setKeepAliveInterval:60]; - - [connection connect]; - - if (![connection isConnected]) { - [connection release], connection = nil; - - STFail(@"Error connecting to database server. No tests were run."); - } - else { - if (![connection selectDB:SPTestDatabaseName]) { - [connection release], connection = nil; - - STFail(@"Error selecting database '%@'. No tests were run.", SPTestDatabaseName); - } - } -} - -/** - * Disconnects the connection if connected. - */ -- (void)tearDown -{ - if (connection && [connection isConnected]) { - [connection disconnect]; - } - - [connection release], connection = nil; -} - -#pragma mark - -#pragma mark Tests - -/** - * Tests the connection's major version number. - */ -- (void)testServerMajorVersion -{ - if ((!connection) || (![connection isConnected])) return; - - STAssertTrue(([connection serverMajorVersion] != 0), @"server major version"); -} - -/** - * Tests the connection's version string. - */ -- (void)testServerVersionString -{ - if ((!connection) || (![connection isConnected])) return; - - STAssertTrue(([[connection serverVersionString] length] > 0), @"server version string"); -} - -/** - * Tests the connection query execution. - */ -- (void)testQueryExexution -{ - if ((!connection) || (![connection isConnected])) return; - - MCPResult *result = [connection queryString:@"SELECT * FROM actor"]; - - if ([connection queryErrored]) { - STFail(@"Query execution failed with error: %@", [connection getLastErrorMessage]); - } - else { - STAssertEquals([result numOfRows], (my_ulonglong)200, @"'actors' table count"); - } -} - -@end -- cgit v1.2.3