Skip to content

Instantly share code, notes, and snippets.

@frootloops
Created August 6, 2021 09:06
Show Gist options
  • Save frootloops/72124c8735b2b7edaedea786c34dc3f9 to your computer and use it in GitHub Desktop.
Save frootloops/72124c8735b2b7edaedea786c34dc3f9 to your computer and use it in GitHub Desktop.
public struct MockFunc<Input, Output> {
public var parameters: [Input] = []
public var result: (Input) -> Output = { _ in fatalError() }
public mutating func callAndReturn(_ input: Input) -> Output {
parameters.append(input)
return result(input)
}
public mutating func returns(_ value: Output) {
result = { _ in value }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment