Implementing ItemListDataProvider
In the previous section, we created a class to act as the data source and delegate for the item list table view. In this section, we will implement its properties and methods. But we first need a test case class for ItemListDataProvider
.
Conducting the first tests
Open Project Navigator and select the ToDoTests group. Add a new Unit Test Case
Class, call it ItemListDataProviderTests
, and choose the Controller
folder as the location to store the file. Add the @testable import ToDo
import statement and remove the two test template methods.
The table view should have two sections: one for unchecked to-do items and the other for checked items. Add the following test to ItemListDataProviderTests
:
func testNumberOfSections_IsTwo() { let sut = ItemListDataProvider() let tableView = UITableView() tableView.dataSource = sut let numberOfSections = tableView.numberOfSections XCTAssertEqual(numberOfSections, 2) }
First, we create an instance...