withIviServiceMockOnMainThread

fun <T : AnyIviServiceBase, R> withIviServiceMockOnMainThread(iviServiceMockClass: KClass<T>, block: T.() -> R): R

Applies block on the iviServiceMockClass instance on the main thread.

Must be called after configuring the mock in the initialIviServiceTestConfiguration or after configuring it by setting iviServiceTestConfiguration. The mock can be used until the configuration is changed by setting iviServiceTestConfiguration.

This overload can only be used when one instance of the iviServiceMockClass is configured. When multiple mock instances are configured, use the withIviServiceMockOnMainThread overload that takes a IviServiceMockIdentifier as argument.

Example usage:

withIviServiceMockOnMainThread(ExampleServiceMock::class) {
properties.intProp = 42
mutableServiceReady = true

coEvery { functions.doSomethingWithReturnValue() } returns 42
}

fun <T : AnyIviServiceBase, R> withIviServiceMockOnMainThread(iviServiceMockIdentifier: IviServiceMockIdentifier<T>, block: T.() -> R): R

Applies block on a mock instance identified by the iviServiceMockIdentifier on the main thread.

Must be called after configuring the mock in the initialIviServiceTestConfiguration or after configuring it by setting iviServiceTestConfiguration. The mock can be used until the configuration is changed by setting iviServiceTestConfiguration.

Example usage:

val mockIdentifier = IviServiceMockIdentifier(
IviServiceId("com.tomtom.ivi.service.example"),
ExampleDiscoverableServiceMock::class
)
withIviServiceMockOnMainThread(mockIdentifier) {
properties.intProp = 42
mutableServiceReady = true

coEvery { functions.doSomethingWithReturnValue() } returns 42
}

In the above example the given block is applied on the ExampleDiscoverableServiceMock class instance with IVI service ID com.tomtom.ivi.service.example.