isObservable<T> method

Matcher isObservable<T>(
  1. String marbles, {
  2. Map<String, T> values = const {},
  3. Object error = 'Error',
})

Creates a matcher for an observable.

Implementation

Matcher isObservable<T>(String marbles,
    {Map<String, T> values = const {}, Object error = 'Error'}) {
  if (this != defaultScheduler || _subscription.isDisposed) {
    throw StateError('Called outside of the scope of this scheduler.');
  }
  final expected =
      TestEventSequence.fromString(marbles, values: values, error: error);
  return isA<Observable<T>>().having((observable) {
    final start = now;
    final events = <TestEvent<T>>[];
    final subscription = observable
        .materialize()
        .map((event) => WrappedEvent(
            now.difference(start).inMilliseconds ~/
                stepDuration.inMilliseconds,
            event))
        .subscribe(Observer.next(events.add));
    while (hasPending && !subscription.isDisposed) {
      advance();
    }
    return TestEventSequence<T>(events, values: values);
  }, 'events', expected);
}