-
-
Save inderisonline/c40cc0249521907ba187f3d9c77a3a2e to your computer and use it in GitHub Desktop.
MqttConnectTest demo code for higher order function as an argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HighOrderDemoTest { | |
private lateinit var highOrderDemo: HighOrderDemo | |
private var connectRemote: ConnectRemote = mockk(relaxed = true) | |
@Before | |
fun before() { | |
highOrderDemo = HighOrderDemo( | |
connectRemote | |
) | |
} | |
@Test | |
fun `test successful connection`() { | |
every { connectRemote.connect(captureLambda<(isConnected: Boolean) -> Unit>()) } answers { | |
lambda<(isConnected: Boolean) -> Unit>().captured.invoke(true) | |
} | |
highOrderDemo.connect { | |
assertEquals(it, true) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment