computation

fun <D> computation(contract: Contract.Computation<D>, data: () -> D): TransmissionTest(source)

Adds a mock computation that provides computed results for the specified contract during testing.

This method creates a mock transformer that provides computation results when other transformers request computation through the specified contract. The result is provided by the lambda function which is called each time the computation is requested.

Return

This TransmissionTest instance for method chaining

Example usage:

transformer.test()
.computation(AnalyticsService.userStatsContract) {
UserStats(loginCount = 5, lastLogin = Date())
}
.testSignal(ProfileSignal.LoadStats) { /* assertions */}

Parameters

C

The computation contract type

contract

The computation contract to mock

data

Lambda function that provides the computation result

Type Parameters

D

The type of data returned by the computation