Last active
December 18, 2017 01:31
-
-
Save BeauNouvelle/420638bec6eddd4bdf667a7678a20d9c to your computer and use it in GitHub Desktop.
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
class MockSession: URLSession { | |
var completionHandler: ((Data, URLResponse, Error) -> Void)? | |
static var mockResponse: (data: Data?, URLResponse: URLResponse?, error: Error?) | |
override class var shared: URLSession { | |
return MockSession() | |
} | |
override func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask { | |
self.completionHandler = completionHandler | |
return MockTask(response: MockSession.mockResponse, completionHandler: completionHandler) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment