diff options
-rw-r--r-- | UnitTests/SPDatabaseCopyTest.m | 29 | ||||
-rw-r--r-- | UnitTests/SPDatabaseRenameTest.m | 25 | ||||
-rw-r--r-- | UnitTests/SPTableCopyTest.m | 35 | ||||
-rw-r--r-- | sequel-pro.xcodeproj/project.pbxproj | 10 |
4 files changed, 42 insertions, 57 deletions
diff --git a/UnitTests/SPDatabaseCopyTest.m b/UnitTests/SPDatabaseCopyTest.m index df4807b9..358e0c1e 100644 --- a/UnitTests/SPDatabaseCopyTest.m +++ b/UnitTests/SPDatabaseCopyTest.m @@ -29,34 +29,27 @@ #import "SPDatabaseCopyTest.h" #import "SPDatabaseCopy.h" #import "SPTableCopy.h" -#import "MCPConnection.h" -#import "SPDatabaseInfo.h" #import "SPLogger.h" @implementation SPDatabaseCopyTest -- (SPDatabaseCopy *) getDatabaseCopyFixture { - SPDatabaseCopy *dbCopy = [[SPDatabaseCopy alloc] init]; - return [dbCopy autorelease]; -} - -- (SPTableCopy *) getTableCopyFixture { - SPTableCopy *tableCopy = [[SPTableCopy alloc] init]; - return [tableCopy autorelease]; +- (SPDatabaseCopy *)getDatabaseCopyFixture +{ + return [[[SPDatabaseCopy alloc] init] autorelease]; } -- (id) getMockConnection { - id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]]; - return mockConnection; +- (SPTableCopy *)getTableCopyFixture +{ + return [[[SPTableCopy alloc] init] autorelease]; } -- (id) getMockDBInfo { - id mockDBInfo = [OCMockObject niceMockForClass:[SPDatabaseInfo class]]; - return mockDBInfo; +- (id)getMockConnection +{ + return [OCMockObject niceMockForClass:[SPMySQLConnection class]]; } -- (void)testCopyDatabase { - +- (void)testCopyDatabase +{ SPDatabaseCopy *dbCopy = [self getDatabaseCopyFixture]; id mockConnection = [self getMockConnection]; [[mockConnection expect] queryString:@"CREATE DATABASE `target_name`"]; diff --git a/UnitTests/SPDatabaseRenameTest.m b/UnitTests/SPDatabaseRenameTest.m index 335e9f34..c0956262 100644 --- a/UnitTests/SPDatabaseRenameTest.m +++ b/UnitTests/SPDatabaseRenameTest.m @@ -23,43 +23,28 @@ // // More info at <http://code.google.com/p/sequel-pro/> -#import <OCMock/OCMock.h> - #import "SPDatabaseRenameTest.h" #import "SPDatabaseRename.h" #import "SPTableCopy.h" -#import "MCPConnection.h" -#import "SPDatabaseInfo.h" #import "SPLogger.h" +#import <OCMock/OCMock.h> + @implementation SPDatabaseRenameTest - (SPDatabaseRename *)getDatabaseRenameFixture { - SPDatabaseRename *dbRename = [[SPDatabaseRename alloc] init]; - - return [dbRename autorelease]; + return [[[SPDatabaseRename alloc] init] autorelease]; } - (SPTableCopy *)getTableCopyFixture { - SPTableCopy *tableCopy = [[SPTableCopy alloc] init]; - - return [tableCopy autorelease]; + return [[[SPTableCopy alloc] init] autorelease]; } - (id)getMockConnection { - id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]]; - - return mockConnection; -} - -- (id)getMockDBInfo -{ - id mockDBInfo = [OCMockObject niceMockForClass:[SPDatabaseInfo class]]; - - return mockDBInfo; + return [OCMockObject niceMockForClass:[SPMySQLConnection class]]; } - (void)testRenameDatabase diff --git a/UnitTests/SPTableCopyTest.m b/UnitTests/SPTableCopyTest.m index f0e31c14..0d146827 100644 --- a/UnitTests/SPTableCopyTest.m +++ b/UnitTests/SPTableCopyTest.m @@ -23,47 +23,54 @@ // // More info at <http://code.google.com/p/sequel-pro/> -#import <OCMock/OCMock.h> #import "SPTableCopy.h" #import "SPTableCopyTest.h" +#import <OCMock/OCMock.h> +#import <SPMySQL/SPMySQL.h> @implementation SPTableCopyTest -- (id) getMockConnection { - id mockConnection = [OCMockObject niceMockForClass:[MCPConnection class]]; - return [mockConnection autorelease]; +- (id)getMockConnection +{ + return [[OCMockObject niceMockForClass:[SPMySQLConnection class]] autorelease]; } -- (id) getMockResult { - id mockResult = [OCMockObject niceMockForClass:[MCPResult class]]; - return mockResult; +- (id)getMockResult +{ + return [OCMockObject niceMockForClass:[SPMySQLResult class]]; } -- (SPTableCopy *) getTableCopyFixture { - SPTableCopy *tableCopy = [[SPTableCopy alloc] init]; - return [tableCopy autorelease]; +- (SPTableCopy *)getTableCopyFixture +{ + return [[[SPTableCopy alloc] init] autorelease]; } -- (void)testCopyTableFromToWithData { +- (void)testCopyTableFromToWithData +{ id mockResult = [self getMockResult]; + unsigned long long varOne = 1; NSValue *valueOne = [NSValue value:&varOne withObjCType:@encode(__typeof__(varOne))]; BOOL varNo = NO; + NSValue *valueNo = [NSValue value:&varNo withObjCType:@encode(BOOL)]; NSArray *resultArray = [[NSArray alloc] initWithObjects:@"", @"CREATE TABLE `table_name` ()", nil]; - [[[mockResult expect] andReturnValue:valueOne] numOfRows]; - [[[mockResult expect] andReturn:resultArray] fetchRowAsArray]; + + [[[mockResult expect] andReturnValue:valueOne] numberOfRows]; + [[[mockResult expect] andReturn:resultArray] getRowAsArray]; id mockConnection = [self getMockConnection]; + [[[mockConnection expect] andReturn:mockResult] queryString:@"SHOW CREATE TABLE `source_db`.`table_name`"]; [[mockConnection expect] queryString:@"CREATE TABLE `target_db`.`table_name` ()"]; [[mockConnection expect] queryString:@"INSERT INTO `target_db`.`table_name` SELECT * FROM `source_db`.`table_name`"]; [[[mockConnection stub] andReturnValue:valueNo] queryErrored]; id tableCopy = [self getTableCopyFixture]; + [tableCopy setConnection:mockConnection]; - [tableCopy copyTable: @"table_name" from: @"source_db" to: @"target_db" withContent: YES]; + [tableCopy copyTable:@"table_name" from:@"source_db" to:@"target_db" withContent:YES]; [mockResult verify]; [mockConnection verify]; [resultArray release]; diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index ff8abd97..b53998c5 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -1409,10 +1409,10 @@ 1198F5B41174EDDE00670590 /* Database Actions */ = { isa = PBXGroup; children = ( - 1198F5C21174EF3F00670590 /* SPDatabaseCopyTest.h */, - 1198F5C31174EF3F00670590 /* SPDatabaseCopyTest.m */, 112730541180788A000737FD /* SPTableCopyTest.h */, 112730551180788A000737FD /* SPTableCopyTest.m */, + 1198F5C21174EF3F00670590 /* SPDatabaseCopyTest.h */, + 1198F5C31174EF3F00670590 /* SPDatabaseCopyTest.m */, 11C210DD1180E9B800758039 /* SPDatabaseRenameTest.h */, 11C210DE1180E9B800758039 /* SPDatabaseRenameTest.m */, ); @@ -3976,7 +3976,7 @@ "-framework", SenTestingKit, "-framework", - MCPKit, + SPMySQL, "-framework", QueryKit, ); @@ -4010,7 +4010,7 @@ "-framework", SenTestingKit, "-framework", - MCPKit, + SPMySQL, "-framework", QueryKit, ); @@ -4043,7 +4043,7 @@ "-framework", SenTestingKit, "-framework", - MCPKit, + SPMySQL, "-framework", OCMock, "-framework", |