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

io.mockk.impl.eval.VerifyBlockEvaluator.kt Maven / Gradle / Ivy

The newest version!
package io.mockk.impl.eval

import io.mockk.CapturingSlot
import io.mockk.MockKGateway.*
import io.mockk.MockKVerificationScope
import io.mockk.impl.recording.AutoHinter
import io.mockk.impl.stub.StubRepository

class VerifyBlockEvaluator(
    callRecorder: () -> CallRecorder,
    val stubRepo: StubRepository,
    autoHinterFactory: () -> AutoHinter
) : RecordedBlockEvaluator(callRecorder, autoHinterFactory), Verifier {

    override fun verify(
        params: VerificationParameters,
        mockBlock: (MockKVerificationScope.() -> Unit)?,
        coMockBlock: (suspend MockKVerificationScope.() -> Unit)?
    ) {
        if (coMockBlock != null) {
            initializeCoroutines()
        }

        callRecorder().startVerification(params)

        val lambda = CapturingSlot>()
        val scope = MockKVerificationScope(callRecorder(), lambda)

        try {
            record(scope, mockBlock, coMockBlock)
        } finally {
            callRecorder().reset()
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy