Permalink
Browse files

implementing unit tests for title of the rows

  • Loading branch information...
1 parent 9451bfb commit 584a6260c9313910df13b183df848bf5d1e9796e @setuid setuid committed Sep 30, 2012
@@ -50,14 +50,57 @@ - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if( pickerView == rootNotePickerView )
- return 21;
+ return 12;
return 0;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
+ NSString* title = nil;
+ if( pickerView == rootNotePickerView )
+ switch (row) {
+ case 0:
+ title = @"A";
+ break;
+ case 1:
+ title = @"A# - Bb";
+ break;
+ case 2:
+ title = @"B";
+ break;
+ case 3:
+ title = @"C";
+ break;
+ case 4:
+ title = @"C# - Db";
+ break;
+ case 5:
+ title = @"D";
+ break;
+ case 6:
+ title = @"D# - Eb";
+ break;
+ case 7:
+ title = @"E";
+ break;
+ case 8:
+ title = @"F";
+ break;
+ case 9:
+ title = @"F# - Gb";
+ break;
+ case 10:
+ title = @"G";
+ break;
+ case 11:
+ title = @"G# - Ab";
+ break;
+ default:
+ break;
+ }
+ return title;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
@@ -25,15 +25,37 @@ -( void ) test_all_picker_views_should_have_one_component
STAssertTrue([dcp numberOfComponentsInPickerView: nil] == 1, @"" );
}
--( void ) test_root_picker_view_should_have_21_rows
+-( void ) test_root_picker_view_should_have_10_rows
{
DCCifraPickerViewController* dcp = [DCCifraPickerViewController cifraPickerViewController];
[self pingView: dcp.view];
UIPickerView* rootPickerView = [dcp valueForKey:@"rootNotePickerView"];
STAssertNotNil( rootPickerView, @"" );
- STAssertTrue( [dcp pickerView: rootPickerView numberOfRowsInComponent:0] == 21, @"" );
+ STAssertTrue( [dcp pickerView: rootPickerView numberOfRowsInComponent:0] == 12, @"" );
+}
+
+-( void ) test_root_picker_view_should_return_all_notes_chromatic_for_rows
+{
+ DCCifraPickerViewController* dcp = [DCCifraPickerViewController cifraPickerViewController];
+ [self pingView: dcp.view];
+
+ UIPickerView* rootPickerView = [dcp valueForKey:@"rootNotePickerView"];
+ STAssertNotNil( rootPickerView, @"" );
+
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:0 forComponent: 0] isEqualToString:@"A"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:1 forComponent: 0] isEqualToString:@"A# - Bb"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:2 forComponent: 0] isEqualToString:@"B"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:3 forComponent: 0] isEqualToString:@"C"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:4 forComponent: 0] isEqualToString:@"C# - Db"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:5 forComponent: 0] isEqualToString:@"D"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:6 forComponent: 0] isEqualToString:@"D# - Eb"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:7 forComponent: 0] isEqualToString:@"E"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:8 forComponent: 0] isEqualToString:@"F"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:9 forComponent: 0] isEqualToString:@"F# - Gb"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:10 forComponent: 0] isEqualToString:@"G"], @"");
+ STAssertTrue( [[dcp pickerView: rootPickerView titleForRow:11 forComponent: 0] isEqualToString:@"G# - Ab"], @"");
}
#pragma mark - Auxilary methods

0 comments on commit 584a626

Please sign in to comment.