TestConsumer


class TestConsumer<T : Any?> : Consumer


An implementation of Consumer to capture values during a test and allows developers to perform assertions on the values.

Parameters
<T : Any?>

the type of the input to the operation

Summary

Public constructors

<T : Any?> TestConsumer()

Public functions

open Unit
accept(t: T)

Records the value in the order it was received.

Unit
assertValues(values: List<T>)

Asserts that the values match the received values.

Public constructors

TestConsumer

<T : Any?> TestConsumer()
Parameters
<T : Any?>

the type of the input to the operation

Public functions

accept

Added in 1.11.0
open fun accept(t: T): Unit

Records the value in the order it was received.

Parameters
t: T

the input argument.

assertValues

fun assertValues(values: List<T>): Unit

Asserts that the values match the received values. This method checks the order and the elements.

Parameters
values: List<T>

expected to be in the TestConsumer

Throws
kotlin.AssertionError

if the values do not match the current values.