Last active
April 25, 2018 17:49
-
-
Save trupin/9e304958670581c4064129bc4302654d 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
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