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

    substitute

    The value that will impostor the response expectation

    criteria

    How 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) -> Bool

    Parameters

    bundle

    Bundle to read the file from

    fileName

    The file name to read and parse

    type

    The type of the response expectation that will determing how to parse the file

    criteria

    How 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

    error

    A error message that will be wrapped in a MockedError

    type

    The type of the response expectation that this applies to

    criteria

    How outgoing requests will be matched on

  • Declaration

    Swift

    public func hijack<T>(endpoint: Endpoint<T>) -> Result<T, Error>?