Skip to content

Instantly share code, notes, and snippets.

@markchristopherng
Last active February 19, 2020 03:22
Show Gist options
  • Save markchristopherng/532630b0bcb693eed97ba9569289c7c1 to your computer and use it in GitHub Desktop.
Save markchristopherng/532630b0bcb693eed97ba9569289c7c1 to your computer and use it in GitHub Desktop.
class GreetingServiceFakeTest {
@Inject
lateinit var greetingService: GreetingService
@Test
fun testGreetingInTheMorning() {
val testModule = module {
bind<TimeService>().toInstance(object : TimeService {
override fun getHourOfDay(): Int = 9
})
}
KTP.openRootScope().installTestModules(toothpickModule, testModule).inject(this)
assertEquals("Good morning, welcome to Toothpick", greetingService.greetings())
Toothpick.reset()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment