public void WhenObservablePollsThenDoesNotComplete() { var waitHandle = new ManualResetEvent(false); var factory = new FakeAsyncRestClientFactory("[{\"Text\":\"blah\", \"Number\":1}]"); var observable = new RestObservable <FakeItem>(factory, new TestSerializerFactory()); var subscription = observable .Poll(Observable.Interval(TimeSpan.FromSeconds(0.5)).Select(x => Unit.Default)) .ObserveOn(TaskPoolScheduler.Default) .Where(x => x.StringValue == "blah") .Subscribe(x => { }, () => waitHandle.Set()); var result = waitHandle.WaitOne(2000); Assert.False(result); subscription.Dispose(); }
public void WhenDisposingPollSubscriptionThenCompletes() { var waitHandle = new ManualResetEvent(false); var factory = new FakeAsyncRestClientFactory("[{\"Text\":\"blah\", \"Number\":1}]"); var observable = new RestObservable <FakeItem>(factory, new TestSerializerFactory()); var subscription = observable .Poll(Observable.Interval(TimeSpan.FromSeconds(0.5)).Select(x => Unit.Default)) .Where(x => x.StringValue == "blah") .Subscribe(x => { }, () => waitHandle.Set()); Task.Factory.StartNew( () => { Thread.Sleep(1000); subscription.Dispose(); }); var result = waitHandle.WaitOne(2000); Assert.True(result); subscription.Dispose(); }