expectAsync4<T, A, B, C, D> function

Func4<T, A, B, C, D> expectAsync4 <T, A, B, C, D>(T callback(A a, B b, C c, D d), { int count: 1, int max: 0, String id, String reason })

Informs the framework that the given callback of arity 4 is expected to be called count number of times (by default 1).

Returns a wrapped function that should be used as a replacement of the original callback.

The test framework will wait for the callback to run the count times before it considers the current test to be complete.

max can be used to specify an upper bound on the number of calls; if this is exceeded the test will fail. If max is 0 (the default), the callback is expected to be called exactly count times. If max is -1, the callback is allowed to be called any number of times greater than count.

Both id and reason are optional and provide extra information about the callback when debugging. id should be the name of the callback, while reason should be the reason the callback is expected to be called.

This method takes callbacks with four arguments. See also expectAsync0, expectAsync1, expectAsync2, expectAsync3, expectAsync5, and expectAsync6 for callbacks with different arity.

Implementation

Func4<T, A, B, C, D> expectAsync4<T, A, B, C, D>(T callback(A a, B b, C c, D d),
    {int count = 1, int max = 0, String id, String reason}) {
  if (Invoker.current == null) {
    throw StateError("expectAsync4() may only be called within a test.");
  }

  return _ExpectedFunction<T>(callback, count, max, id: id, reason: reason)
      .max4;
}