Created
January 31, 2022 09:30
-
-
Save micHar/2dea805443dc6b242d90b4460e0d6375 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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