Skip to content

Instantly share code, notes, and snippets.

@micHar
Created January 31, 2022 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micHar/2dea805443dc6b242d90b4460e0d6375 to your computer and use it in GitHub Desktop.
Save micHar/2dea805443dc6b242d90b4460e0d6375 to your computer and use it in GitHub Desktop.
protocol Grinder {
func grind(_ coffee: Coffee)
}
class GrinderMock: Grinder {
private(set) var timesUsed: Int = 0
func grind(_ coffee: Coffee) {
timesUsed += 1
}
}
class CoffeeMakerTest: XCTestCase {
func test_grinder_used_once_when_coffee_made() {
let grinder = GrinderMock()
let sut = CoffeeMaker(grinder: grinder)
sut.makeCoffee()
XCTAssertEqual(grinder.timesUsed, 1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment