All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lightningkite.lightningserver.email.TestEmailClient.kt Maven / Gradle / Ivy

The newest version!
package com.lightningkite.lightningserver.email

/**
 * A concrete implementation of EmailClient that will is similar to ConsoleEmailClient but with more options
 * You can turn off the console printing
 * It stores the last message sent
 * You can set a lambda for getting send events
 * This is useful for Unit Tests
 */

object TestEmailClient : EmailClient {
    var onEmailSent: ((Email)->Unit)? = null
    var lastEmailSent: Email? = null
        private set
    var printToConsole: Boolean = false

    override suspend fun send(email: Email) {
        lastEmailSent = email
        onEmailSent?.invoke(email)
        if (printToConsole) ConsoleEmailClient.send(email)
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy