Created
September 5, 2017 21:10
-
-
Save ncreated/b4f751555f79ae54cf929dc6d742f643 to your computer and use it in GitHub Desktop.
Medium blogpost snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_givenTask_whenExecuted_itUpdatesStatusInSpecificOrder() { | |
let task = Task() | |
let mockDelegate = MockTaskStatusDelegate() | |
task.statusDelegate = mockDelegate | |
let downloadingExpectation = self.expectation(description: "status changes to .downloading") | |
let processingExpectation = self.expectation(description: "status changes to .processing") | |
let finishedExpectation = self.expectation(description: "status changes to .finished") | |
mockDelegate.didCall_taskDidChangeStatus = { (_, status) in | |
switch status { | |
case .downloading: | |
downloadingExpectation.fulfill() | |
case .processing: | |
processingExpectation.fulfill() | |
case .finished: | |
finishedExpectation.fulfill() | |
default: | |
XCTFail() | |
} | |
} | |
task.execute() | |
wait(for: [downloadingExpectation, processingExpectation, finishedExpectation], | |
timeout: 0.5, | |
enforceOrder: true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment