softCheckAsync<T> function

Future<CheckFailure?> softCheckAsync<T>(
  1. T value,
  2. AsyncCondition<T> condition
)

Checks whether value satisfies all expectations invoked in condition, without throwing an exception.

The future will complete to null if all expectations are satisfied, otherwise it will complete to the CheckFailure for the first expectation that fails.

In contrast to softCheck, asynchronous expectations are allowed in condition.

Implementation

Future<CheckFailure?> softCheckAsync<T>(
    T value, AsyncCondition<T> condition) async {
  CheckFailure? failure;
  final subject = Subject<T>._(_TestContext._root(
    value: _Present(value),
    fail: (f) {
      failure ??= f;
    },
    allowAsync: true,
    allowUnawaited: false,
  ));
  await condition(subject);
  return failure;
}