I'm not sure how I can implement that my mock UITableView
object answers correctly for indexPathsForSelectedRows
.
In my App the user can (in editing state) select cells in a table view, which represents the files/folders of a given directory.
Once the user selects a folder item the previously selected files items should be deselected. My test (using OCHamcrest/OCMockito) looks like this.
- (void)test_tableViewwillSelectRowAtIndexPath_DeselectsPreviouslySelectedCells
{
// given
[given(self.mockTableView.editing) willReturnBool:YES];
// when
[self.sut tableView:self.mockTableView willSelectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:SectionIdFile]];
[self.sut tableView:self.mockTableView willSelectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:SectionIdFolder]];
// then
}
The problem is that I can verify that the file item is selected but I can't ask the the mockTableView for its selected rows. Could somebody tell me how to handle that? Do I have to record the tableView:selectRowAtIndexPath:animated:scrollPosition:
calls myself and provide the correct answer when the tableView is asked for that information?