withComputation
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()
.withComputation(AnalyticsService.userStatsContract) {
UserStats(loginCount = 5, lastLogin = Date())
}
.testSignal(ProfileSignal.LoadStats) { /* assertions */}
Parameters
The computation contract type
The type of data returned by the computation
The computation contract to mock
Lambda function that provides the computation result
Adds a mock computation with arguments 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 with arguments through the specified contract. The result is provided by the lambda function which is called each time the computation is requested with arguments.
Note: Currently the arguments are not passed to the data lambda function due to the mock implementation. This will be improved in future versions.
Return
This TransmissionTest instance for method chaining
Example usage:
transformer.test()
.withComputation(SearchService.searchUsersContract) {
listOf(User("john", "john@example.com"))
}
.testSignal(SearchSignal.SearchUsers("john")) { /* assertions */}
Parameters
The computation contract type
The type of data returned by the computation
The type of arguments passed to the computation
The computation contract to mock
Lambda function that provides the computation result