Hari K
10/18/2021, 8:15 AMClock.System.now()
Grégory Lureau
10/18/2021, 8:27 AMnow()
) so that I can mock the class and pass the value I want without thinking about the Kotlin stdlib mock-ability.hfhbd
10/18/2021, 9:04 AMClock
interface and increase the internal counter in your test.
@ExperimentalTime
class MockClock(private var durationSinceEpoch: Duration = Duration.ZERO) : Clock {
override fun now(): Instant = Instant.fromEpochMilliseconds(durationSinceEpoch.inWholeMilliseconds)
operator fun plusAssign(duration: Duration) {
durationSinceEpoch + duration
}
}