Skip to content

Instantly share code, notes, and snippets.

@victorpanitz
Created August 17, 2020 00:36
Show Gist options
  • Save victorpanitz/b994e9d193d324fd8df8f39fa57d818d to your computer and use it in GitHub Desktop.
Save victorpanitz/b994e9d193d324fd8df8f39fa57d818d to your computer and use it in GitHub Desktop.
func test_cancellAllTasks_givenExistsActiveTasks_shouldCancellAllOfThem() {
URLSession.initSwizzle()
let sut = Network.shared
let taskLorem = URLSessionTaskSpy()
let taskIpsum = URLSessionTaskSpy()
FakeURLSession.tasksToBeReturned = [taskLorem, taskIpsum]
XCTAssertFalse(taskLorem.cancelCalled)
XCTAssertFalse(taskIpsum.cancelCalled)
sut.cancelAllTasks()
XCTAssertTrue(taskLorem.cancelCalled)
XCTAssertTrue(taskIpsum.cancelCalled)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment