commonMain.io.mockk.impl.recording.CallRoundBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockk-jvm Show documentation
Show all versions of mockk-jvm Show documentation
Mocking library for Kotlin
package io.mockk.impl.recording
import io.mockk.Invocation
import io.mockk.Matcher
import io.mockk.impl.log.SafeToString
import kotlin.reflect.KClass
class CallRoundBuilder(val safeToString: SafeToString) {
val signedMatchers = mutableListOf()
val signedCalls = mutableListOf()
fun addMatcher(matcher: Matcher<*>, sigValue: Any) {
signedMatchers.add(SignedMatcher(matcher, sigValue))
}
fun addSignedCall(
retValue: Any?,
tempMock: Boolean,
retType: KClass<*>,
invocation: Invocation
) {
val signedCall = SignedCall(
retValue,
tempMock,
retType,
invocation.self,
invocation.method,
invocation.args,
safeToString.exec { invocation.toString() }
)
signedCalls.add(signedCall)
}
fun addWasNotCalled(list: List) {
for (self in list) {
signedCalls.add(
SignedCall(
Unit,
false,
Unit::class,
self,
WasNotCalled.method,
listOf(),
safeToString.exec { "$self wasNot Called" }
)
)
}
}
fun build() = CallRound(signedCalls.toList(), signedMatchers.toList())
}