expectOneWhere method
Matches exactly one request without consuming candidates on failure.
Implementation
PendingRequest expectOneWhere(bool Function(HttpRequest) predicate,
{String description = 'matching request'}) {
final candidates = _pending
.where((item) => !item.matched && predicate(item.request))
.toList();
if (candidates.length != 1) {
throw StateError('Expected one $description, found ${candidates.length}. '
'Outstanding: $_outstanding');
}
candidates.single.matched = true;
return candidates.single;
}