ScriptedRequest<TId, TValue, TKey> class

A BatchRequest that replays a script of outcomes, one per call.

Lets a test say "first call throws, second returns 0, third returns 12.5" without a mock, and records exactly which ids each call was asked for — the property a batching layer exists to control and the one a cache-only assertion cannot see.

Constructors

ScriptedRequest(List<FutureOr<BatchOutcome<TId, TValue>> Function(List<TId> ids, TKey key)> steps)
Creates a request that returns steps in order.
ScriptedRequest.always(TValue resolve(TId id))
Creates a request that always resolves ids through resolve.
factory
ScriptedRequest.alwaysFailing(Object error)
Creates a request that always throws error.
factory

Properties

callCount → int
How many requests have been made.
no setter
calls → List<List<TId>>
The ids each call was asked for, in call order.
final
hashCode → int
The hash code for this object.
no setterinherited
idCount → int
The total number of ids across every call — equal to callCount times the batch size only if no de-duplication happened.
no setter
keys → List<TKey>
The keys each call was made under, in call order.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
steps → List<FutureOr<BatchOutcome<TId, TValue>> Function(List<TId> ids, TKey key)>
The scripted steps, each producing an outcome or throwing.
final

Methods

call(List<TId> ids, TKey key) → Future<BatchOutcome<TId, TValue>>
The BatchRequest to hand to a fetcher.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited