Skip to content

Instantly share code, notes, and snippets.

@lgrammel
Last active September 11, 2020 17:30
Show Gist options
  • Save lgrammel/36bd1ab6e760f7442edb5a06bedab366 to your computer and use it in GitHub Desktop.
Save lgrammel/36bd1ab6e760f7442edb5a06bedab366 to your computer and use it in GitHub Desktop.
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import java.time.Instant
class MyObject(
private val currentInstant: () -> Instant = { Instant.now() }
) {
fun myMethod() = Pair("test", currentInstant())
}
class MyObjectTest {
@Test
fun `my test`() {
val testInstant = Instant.ofEpochSecond(100)
val underTest = MyObject({ testInstant })
Assertions.assertEquals(
Pair("test", testInstant),
underTest.myMethod()
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment