mirror of
https://github.com/mas-cli/mas
synced 2024-11-26 05:20:18 +00:00
24 lines
555 B
Swift
24 lines
555 B
Swift
//
|
|
// URLSessionDataTaskMock .swift
|
|
// MasKitTests
|
|
//
|
|
// Created by Ben Chatelain on 1/5/19.
|
|
// Copyright © 2019 mas-cli. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
// Partial mock subclassing the original class
|
|
class URLSessionDataTaskMock: URLSessionDataTask {
|
|
private let closure: () -> Void
|
|
|
|
init(closure: @escaping () -> Void) {
|
|
self.closure = closure
|
|
}
|
|
|
|
// We override the 'resume' method and simply call our closure
|
|
// instead of actually resuming any task.
|
|
override func resume() {
|
|
closure()
|
|
}
|
|
}
|