MockDataClientHijacker
public class MockDataClientHijacker : ClientHijacker
A ClientHijacker implementation that can register fake response substitutes and errors in memory.
-
Undocumented
Declaration
Swift
public func clear() -
Registers a hijacker with a substitute value
Declaration
Swift
public func registerSubstitute<T>(_ substitute: T, requestThatMatches criteria: RequestMatchingCriteria)Parameters
substituteThe value that will impostor the response expectation
criteriaHow outgoing requests will be matched on
-
Registers a hijacker that will read from file and store the substitute
Declaration
Swift
@discardableResult public func registerJsonFileContentSubstitute<T: Decodable>(for type: T.Type, requestThatMatches criteria: RequestMatchingCriteria, bundle: Bundle, fileName: String) -> BoolParameters
bundleBundle to read the file from
fileNameThe file name to read and parse
typeThe type of the response expectation that will determing how to parse the file
criteriaHow outgoing requests will be matched on
-
Registers a hijacker that will error out with the provided error message
Declaration
Swift
public func registerError<T>(_ error: String, for type: T.Type, requestThatMatches criteria: RequestMatchingCriteria)Parameters
errorA error message that will be wrapped in a MockedError
typeThe type of the response expectation that this applies to
criteriaHow outgoing requests will be matched on
-
Declaration
Swift
public func hijack<T>(endpoint: Endpoint<T>) -> Result<T, Error>?
MockDataClientHijacker Class Reference