Created
July 25, 2018 16:27
-
-
Save andru255/ff3f447d8cce7b8dcecc95e6b677d505 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 MockBookFinder: BookFinderProtocol { | |
private var adapter: NetworkAdapter | |
private var totalSearch: Int | |
public init(adapter: NetworkAdapter){ | |
self.adapter = adapter | |
self.totalSearch = 0 | |
} | |
public func searchBy(author: String, success:((_ data:[BookModel?]) -> Void )? = nil, fail: FailCallback = nil) { | |
let dataFake:[BookModel] = [ | |
BookModel(id: "a", title: "five cities", author: [ "jhon doe" ]) | |
] | |
self.adapter.requestServiceSuccess( | |
url: "fake", | |
success: { _ in | |
if let successCallback = success { | |
successCallback(dataFake) | |
} | |
} | |
) | |
totalSearch += 1 | |
} | |
public func searchByFail(author: String, success:((_ data:[BookModel?]) -> Void )? = nil, fail:FailCallback = nil){ | |
self.adapter.requestServiceFail( | |
url: "fake", | |
fail: fail | |
) | |
totalSearch += 1 | |
} | |
public func getTotalSearch() -> Int { | |
return self.totalSearch | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment