Slide 32
Slide 32 text
Stub
class Messenger(private val templateEngine: TemplateEngine,
private val mailServer: MailServer) {
fun sendMessage(client: Client, template: Template) {
val msgContent: String =
templateEngine.prepare(template, client)
mailServer.send(client.getEmail(), msgContent)
}
}
@Test
fun testStub(){
val templateEngine = mock(TemplateEngine::class.java)
val sut = Messenger(mailServer, templateEngine)
`when`(templateEngine.prepare(template, client))
.thenReturn(MSG_CONTENT)
sut.sendMessage(client, template)
}