Permalink
Browse files

Fix tests.

  • Loading branch information...
1 parent a4de128 commit d379e576be7da59654cca1466e05cf2a26ff47a0 @jdzak jdzak committed May 23, 2012
Showing with 24 additions and 20 deletions.
  1. +12 −8 NCSNavField/ContactTable.m
  2. +11 −11 NCSNavFieldTests/ContactTableTest.m
  3. +1 −1 NCSNavFieldTests/RestKitSettingsTest.m
View
@@ -132,16 +132,20 @@ - (void)addSection:(Section*)section to:(NSMutableArray*)sections{
- (NSString*) ReplaceFirstNewLine:(NSString*) original {
- NSMutableString * newString = [NSMutableString stringWithString:original];
-
- NSRange foundRange = [original rangeOfString:@"\n"];
- if (foundRange.location != NSNotFound)
- {
- [newString replaceCharactersInRange:foundRange
- withString:@""];
+ NSMutableString* trim = nil;
+ if (original) {
+ trim = [[[NSMutableString stringWithString:original] retain ]autorelease];
+
+ NSRange foundRange = [original rangeOfString:@"\n"];
+ if (foundRange.location != NSNotFound)
+ {
+ [trim replaceCharactersInRange:foundRange
+ withString:@""];
+ }
+
}
- return [[newString retain] autorelease];
+ return trim;
}
@@ -53,15 +53,15 @@ - (void) testStartContactRow {
NSArray* sections = [self generateSections];
Section* s3 = [sections objectAtIndex:3];
Row* s3r0 = [s3.rows objectAtIndex:0];
- STAssertEqualObjects(s3r0.text, @"Start Contact", @"Wrong value");
+ STAssertEqualObjects(s3r0.text, @"Start Contact for Birth Event", @"Wrong value");
}
- (void) testContinueContactRow {
c.initiated = YES;
NSArray* sections = [self generateSections];
Section* s3 = [sections objectAtIndex:3];
Row* s3r0 = [s3.rows objectAtIndex:0];
- STAssertEqualObjects(s3r0.text, @"Continue Contact", @"Wrong value");
+ STAssertEqualObjects(s3r0.text, @"Continue Contact for Birth Event", @"Wrong value");
}
- (void)testBirthInstrument {
@@ -71,9 +71,9 @@ - (void)testBirthInstrument {
Row* s4r0 = [s4.rows objectAtIndex:0];
Row* s4r1 = [s4.rows objectAtIndex:1];
STAssertEquals([sections count], 5U, @"Wrong number of sections");
- STAssertEqualObjects(s4.name, @"Birth Event", @"Wrong value");
- STAssertEqualObjects(s4r0.text, @"Birth Instrument", @"Wrong value");
- STAssertEqualObjects(s4r1.text, @"Birth Instrument Details", @"Wrong value");
+ STAssertEqualObjects(s4.name, @"Scheduled Activities", @"Wrong value");
+ STAssertEqualObjects(s4r0.text, @"Birth Event Instrument", @"Wrong value");
+ STAssertEqualObjects(s4r1.text, @"Birth Event Activity Details", @"Wrong value");
}
- (void)testPregnancyAndBirthInstruments {
@@ -87,12 +87,12 @@ - (void)testPregnancyAndBirthInstruments {
Row* s5r0 = [s5.rows objectAtIndex:0];
Row* s5r1 = [s5.rows objectAtIndex:1];
STAssertEquals([sections count], 6U, @"Wrong number of sections");
- STAssertEqualObjects(s4.name, @"Birth Event", @"Wrong value");
- STAssertEqualObjects(s4r0.text, @"Birth Instrument", @"Wrong value");
- STAssertEqualObjects(s4r1.text, @"Birth Instrument Details", @"Wrong value");
- STAssertEqualObjects(s5.name, @"Pregnancy Event", @"Wrong value");
- STAssertEqualObjects(s5r0.text, @"Pregnancy Instrument", @"Wrong value");
- STAssertEqualObjects(s5r1.text, @"Pregnancy Instrument Details", @"Wrong value");
+ STAssertEqualObjects(s4.name, @"Scheduled Activities", @"Wrong value");
+ STAssertEqualObjects(s4r0.text, @"Birth Event Instrument", @"Wrong value");
+ STAssertEqualObjects(s4r1.text, @"Birth Event Activity Details", @"Wrong value");
+ STAssertEqualObjects(s5.name, @"Scheduled Activities", @"Wrong value");
+ STAssertEqualObjects(s5r0.text, @"Pregnancy Event Instrument", @"Wrong value");
+ STAssertEqualObjects(s5r1.text, @"Pregnancy Event Activity Details", @"Wrong value");
}
- (NSArray*) generateSections {
@@ -91,7 +91,7 @@ - (void)testGeneralDeserialization {
" \"contacts\":[ "
" { "
" \"contact_id\":\"c1\", "
- " \"date\":\"2009-03-07\", "
+ " \"contact_date\":\"2009-03-07\", "
" \"start_time\": \"10:28\", "
" \"events\":[ "
" { "

0 comments on commit d379e57

Please sign in to comment.