thanksforallthefish
09/18/2019, 7:31 AMfun updateParticipant(participant: Participant, update: Participant.() -> Unit)
?
I am trying with
val participantOrchestrationService: ParticipantOrchestrationService = mockk(relaxed = true)
val dummy = Participant()
val update = slot<Participant.() -> Unit>()
every { participantOrchestrationService.updateParticipant(dummy) { capture(update) } } just Runs
update.captured(dummy)
dummy should {
it.state == State.inactive
}
but getting kotlin.UninitializedPropertyAccessException: lateinit property captured has not been initialized
any suggestion?every { participantOrchestrationService.updateParticipant(dummy, captureLambda()) } answers { lambda<Participant.() -> Unit>().invoke(dummy) }
instead of the original every
block (and remove update
oleksiyp
09/19/2019, 4:42 AMthanksforallthefish
09/19/2019, 6:29 AMupdateParticipant
is fun updateParticipant(participant: Participant, update: Participant.() -> Unit = {}) : Unit
the every
block should be every { participantOrchestrationService.updateParticipant(dummy, capture(update)) } just Runs
, having capture
in a lambda itself satisfied the compiler, but ofc the capturing itself never run. It was kinda of a dummy mistake.
sorry for wasting your timeoleksiyp
09/19/2019, 7:00 AM