Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#7] fixed tests to work with route changes.
- Loading branch information
Showing
7 changed files
with
164 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#define DOG_OWNER 1 | ||
#define PERSON 2 | ||
#define PERSON_DESTROY 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// PersonTest.h | ||
// objective_resource | ||
// | ||
// Created by James Burka on 1/27/09. | ||
// Copyright 2009 Burkaprojects. All rights reserved. | ||
// | ||
|
||
#import "GTMSenTestCase.h" | ||
|
||
|
||
|
||
@interface PersonTest : SenTestCase { | ||
|
||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// PersonTest.m | ||
// objective_resource | ||
// | ||
// Created by James Burka on 1/27/09. | ||
// Copyright 2009 Burkaprojects. All rights reserved. | ||
// | ||
|
||
#import "PersonTest.h" | ||
#import "Person.h" | ||
#import "ItemIds.h" | ||
|
||
|
||
@implementation PersonTest | ||
|
||
-(void) setUp { | ||
[ObjectiveResource setSite:@"http://localhost:3000/"]; | ||
[ObjectiveResource setResponseType:JSONResponse]; | ||
//[ObjectiveResource setResponseType:XmlResponse]; | ||
} | ||
|
||
-(void) testPersonDelete { | ||
int count = [[Person findAll]count]; | ||
Person *person = [Person find:[NSString stringWithFormat:@"%i",PERSON_DESTROY]]; | ||
STAssertTrue([person destroy], @"Should have been true"); | ||
NSArray *people = [Person findAll]; | ||
STAssertTrue((count-1) == [people count], @"Should have %i people , %d found" ,count ,[people count]); | ||
|
||
} | ||
|
||
-(void) testPersonCreate { | ||
BOOL found = NO; | ||
Person *toCreate = [[Person alloc] init]; | ||
toCreate.name = @"Daniel Waterhouse"; | ||
STAssertTrue( [toCreate create], @"Should have been true"); | ||
NSArray *people = [Person findAll]; | ||
|
||
for(Person *person in people) { | ||
if([toCreate isEqual:person]) { | ||
found = YES; | ||
} | ||
} | ||
STAssertTrue(found, @"Did not find the new person : %@",toCreate.name); | ||
} | ||
|
||
-(void) testPersonUpdate { | ||
BOOL found = NO; | ||
Person *toUpdate = [Person find:[NSString stringWithFormat:@"%i",PERSON]]; | ||
toUpdate.name = @"America Shaftoe"; | ||
STAssertTrue( [toUpdate save], @"Should have been true"); | ||
NSArray *people = [Person findAll]; | ||
for(Person *person in people) { | ||
if([toUpdate isEqual:person] && [toUpdate.name isEqualToString:person.name]) { | ||
found = YES; | ||
} | ||
} | ||
STAssertTrue(found, @""); | ||
} | ||
|
||
-(void) testFindPerson { | ||
NSArray * people = [Person findAll]; | ||
Person *toFind = (Person *)[people objectAtIndex:0]; | ||
STAssertTrue([toFind isEqual:[Person find:toFind.personId]], @"Should of returned %@",toFind.name); | ||
} | ||
|
||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters