Checking and unchecking items

The last thing we need to make sure in ItemListDataProvider is that we can check and uncheck items and that they can then change sections. Unfortunately, like in the last test, we need to invoke the responsible data source method directly in the test. We would like to have some kind of high-level method to call to simulate the user tapping the Check and Uncheck buttons, such as in numberOfRows(inSection:), but UIKit does not provide these. We will see how to use UI tests to simulate the taps of the user later in the book. Here, we will use the data source method to do this. Add the following test to ItemListDataProviderTests:

func test_CheckingAnItem_ChecksItInTheItemManager() { sut.itemManager?.add(ToDoItem(title: ...

Get Test-Driven iOS Development with Swift 4 - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.