NetworkingMocker

public final class NetworkingMocker

NetworkingMocker provides a way of storing and retrieving mock reponse objects for both MockURLProtocol and your code

  • Enum used to supply the http version for the ResponseConfiguration

    See more

    Declaration

    Swift

    public enum HTTPVersion : String
  • Configuration object for the response returned by MockURLProtocol

    See more

    Declaration

    Swift

    public struct ResponseConfiguration
  • Storage for mocks - They key is the URL given to the URLRequest or URLSessionDataTask

    Declaration

    Swift

    public static var mocks: [URL : NetworkingMocker.ResponseConfiguration] { get set }
  • Clears the mocks dictionary

    Declaration

    Swift

    public static func clearMocks()
  • Adds a mock to the mocks dictionary using the url as the key

    Declaration

    Swift

    public static func addMockConfiguration(_ mock: ResponseConfiguration, for url: URL)
  • Returns the mock for the url provided. Returns nil if no key matches.

    Declaration

    Swift

    public static func getMockConfiguration(for url: URL) -> ResponseConfiguration?