commonMain.com.copperleaf.ballast.test.internal.BallastScenarioScopeImpl.kt Maven / Gradle / Ivy
package com.copperleaf.ballast.test.internal
import com.copperleaf.ballast.BallastInterceptor
import com.copperleaf.ballast.BallastLogger
import com.copperleaf.ballast.InputStrategy
import com.copperleaf.ballast.test.BallastScenarioInputSequenceScope
import com.copperleaf.ballast.test.BallastScenarioScope
import com.copperleaf.ballast.test.TestResults
import com.copperleaf.ballast.test.internal.vm.TestInterceptorWrapper
import com.copperleaf.ballast.test.internal.vm.TestViewModel
import kotlin.time.Duration
internal class BallastScenarioScopeImpl(
override val name: String
) : BallastScenarioScope {
internal var givenBlock: (() -> State)? = null
internal lateinit var onInputSequenceBlock:
suspend BallastScenarioInputSequenceScope.() -> Unit
internal lateinit var verifyBlock: TestResults.() -> Unit
internal var solo: Boolean = false
internal var skip: Boolean = false
internal var logger: ((String)->BallastLogger)? = null
internal var timeout: Duration? = null
internal var inputStrategy: InputStrategy? = null
internal val interceptors: MutableList<() -> BallastInterceptor, Events, State>> =
mutableListOf()
override fun solo() {
this.solo = true
}
override fun skip() {
this.skip = true
}
override fun logger(logger: (String)->BallastLogger) {
this.logger = logger
}
override fun timeout(timeout: () -> Duration) {
this.timeout = timeout()
}
override fun inputStrategy(inputStrategy: () -> InputStrategy) {
this.inputStrategy = inputStrategy()
}
override fun addInterceptor(interceptor: () -> BallastInterceptor) {
this.interceptors += { TestInterceptorWrapper(interceptor()) }
}
override fun given(block: () -> State) {
givenBlock = block
}
override fun running(block: suspend BallastScenarioInputSequenceScope.() -> Unit) {
onInputSequenceBlock = block
}
override fun resultsIn(block: TestResults.() -> Unit) {
verifyBlock = block
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy