Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
final class KeyValueStoreSpy: KeyValueStoring {
// MARK: - Records
private(set) var keyRecords = [String]()
private(set) var valueRecords = [StoreValueRepresentable]()
// MARK: - Stubs
var getEntryResultStub: [String: Result<Any?, MovieStoreError>]()
// MARK: - Implementation
func getValue<Value: StoreValueRepresentable>(for key: String, completion: @escaping (Result<Value?, StoreError>) -> Void) {
keyRecords.append(key)
completion(completionResultStub)
}
func set(value: StoreValueRepresentable, for key: String) {
valueRecords.append(value)
keyRecords.append(key)
}
}
final class ClientSpy: ClientProtocol {
// MARK: - Records
private(set) var pathRecords = [String]()
// MARK: - Stubs
var getResultStub = [String: Result<Any, ClientError>]()
// MARK: - Implementation
func get<Model: Decodable>(path: String, completion: @escaping (Result<Model, ClientError>) -> Void) {
pathRecords.append(path)
let result = getResultStub[path] as! Result<Model, ClientError>
completion(result)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment