Skip to content

Instantly share code, notes, and snippets.

@Kdan
Last active January 26, 2021 14:28
Show Gist options
  • Save Kdan/4d724be1ccdccfca32a9ba63c0219eb5 to your computer and use it in GitHub Desktop.
Save Kdan/4d724be1ccdccfca32a9ba63c0219eb5 to your computer and use it in GitHub Desktop.
class PresenterMock: Mock<PresenterMock.Functions>, Presenter {
enum Functions: FunctionName {
case present = "present(title:description:)"
}
func present(title: String, description: String) { log(parameters: (title, description)) }
}
/* In the ContentHandlerTests */
func testHandlePositiveInput() {
handler.handleInput(5)
let function = presenterMock.calls(with: .present)
XCTAssertNotNil(function)
XCTAssertEqual(function?.numberOfCalls, 1)
let parameters = function?.calls.last as? (String, String)
XCTAssertEqual(parameters?.0, "Positive")
XCTAssertEqual(parameters?.1, "Great input")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment