Spy test double: verifying collaboration

As Stub verifies the indirect input, a Test Spy permits us to verify the indirect output, exposing a way that indicates whether the functions in the Spy were called during the test.
Let's consider a variation of the TaskManager that we implemented in the Dummy example, Dummy test double: when we don't need to test the collaborator, that manages the tasks in a remote server. We want to verify that the tasks are refreshed, fetching them from the server when TaskManager is constructed.
The code for the manager is the following:

protocol TaskManagerService {
func fetchTask(completion: ([Task]) -> Void)
func sync(tasks: [Task])
}

class TaskManager {
private let service: TaskManagerService
private var tasks = [Task]()

init(service: TaskManagerService) {
self.service = service
self.service.fetchTask { [weak self] tasks in
self?.tasks = tasks
}
}
}

To verify the call, the Spy has a Boolean property that is set to true when the fetch function is called:

class SpyTaskManagerService: TaskManagerService {
private(set) var fetchHasBeenCalled = false

func fetchTask(completion: ([Task]) -> Void) {
fetchHasBeenCalled = true
}

func sync(tasks: [Task]) { }
}

The test is as follows:

func testTasksAreFetchedInStartup() {
let service = SpyTaskManagerService()
_ = TaskManager(service: service)
XCTAssertTrue(service.fetchHasBeenCalled)
}