expectAsync0< T> function
Informs the framework that the given callback
of arity 0 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 zero arguments. See also expectAsync1, expectAsync2, expectAsync3, expectAsync4, expectAsync5, and expectAsync6 for callbacks with different arity.
Implementation
Func0<T> expectAsync0<T>(T callback(),
{int count = 1, int max = 0, String id, String reason}) {
if (Invoker.current == null) {
throw StateError("expectAsync0() may only be called within a test.");
}
return _ExpectedFunction<T>(callback, count, max, id: id, reason: reason)
.max0;
}