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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.