Removing all items

The ItemManager class needs to provide a method to remove all items. Add the following code to ItemManagerTests:

func test_RemoveAll_ResultsInCountsBeZero() { 
    sut.add(ToDoItem(title: "Foo")) 
  sut.add(ToDoItem(title: "Bar")) 
  sut.checkItem(at: 0) 
   

  XCTAssertEqual(sut.toDoCount, 1) 
  XCTAssertEqual(sut.doneCount, 1) 
   

  sut.removeAll() 
} 

This code adds two to-do items to the manager and checks one item. Then, it asserts that the count of the items has the expected values and calls removeAll().

The code does not compile because removeAll() is not implemented yet. Add the minimal implementation needed to make the test code compilable:

func removeAll() { 
} 

Now, add the following assertions to test_RemoveAll_ResultsInCountsBeZero() ...

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.