public IExpectObservable <T> ExpectObservable <T>(IObservable <T> observable, string?subscriptionMarbles = null) { var actual = new List <Recorded <Notification <T> > >(); var flushTest = new FlushableTest <Recorded <Notification <T> > >(actual); var subscriptionParsed = MarbleParser.Instance.ParseAsSubscriptions(subscriptionMarbles, FrameTimeFactor); var subscriptionFrame = subscriptionParsed.Subscribe == Subscription.Infinite ? 0 : subscriptionParsed.Subscribe; var unsubscriptionFrame = subscriptionParsed.Unsubscribe; IDisposable?subscription = null; Schedule(Unit.Default, TimeSpan.FromTicks(subscriptionFrame - 1), (a, b) => { subscription = observable .Materialize() .Where(x => Clock >= subscriptionFrame && Clock <= unsubscriptionFrame) .Subscribe(x => { actual.Add(new Recorded <Notification <T> >(Clock, x)); }); return(subscription); }); Schedule(Unit.Default, TimeSpan.FromTicks(unsubscriptionFrame), (a, b) => { Interlocked.Exchange(ref subscription, null)?.Dispose(); return(Disposable.Empty); }); _flushTests.Add(flushTest); return(new ExpectableObservable <T>(flushTest, FrameTimeFactor, MarbleParser.Instance, _assertFactory)); }
public IExpectSubscriptions ExpectSubscriptions(IEnumerable <Subscription> actualSubscriptions) { var flushTest = new FlushableTest <Subscription>(actualSubscriptions); _flushTests.Add(flushTest); return(new ExpectableSubscriptions(flushTest, FrameTimeFactor, MarbleParser.Instance, _assertFactory)); }