NetNewsWire/Account/Tests/AccountTests/Feedly/TestGetStreamIdsService.swift

30 lines
942 B
Swift
Raw Normal View History

//
2024-04-07 16:09:23 -07:00
// TestGetStreadIDsService.swift
// AccountTests
//
// Created by Kiel Gillard on 29/10/19.
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
//
import XCTest
@testable import Account
2024-04-07 16:09:23 -07:00
final class TestGetStreadIDsService: FeedlyGetStreamIDsService {
2024-04-07 16:09:23 -07:00
var mockResult: Result<FeedlyStreamIDs, Error>?
var parameterTester: ((FeedlyResourceID, String?, Date?, Bool?) -> ())?
var getStreadIDsExpectation: XCTestExpectation?
2024-04-07 16:09:23 -07:00
func getStreamIDs(for resource: FeedlyResourceID, continuation: String?, newerThan: Date?, unreadOnly: Bool?, completion: @escaping (Result<FeedlyStreamIDs, Error>) -> ()) {
guard let result = mockResult else {
XCTFail("Missing mock result. Test may time out because the completion will not be called.")
return
}
parameterTester?(resource, continuation, newerThan, unreadOnly)
DispatchQueue.main.async {
completion(result)
2024-04-07 16:09:23 -07:00
self.getStreadIDsExpectation?.fulfill()
}
}
}