Exemplo n.º 1
0
        public void ToAsyncEnumerable4()
        {
            var ex         = new Exception("Bang!");
            var subscribed = false;

            var xs = new MyObservable <int>(obs =>
            {
                subscribed = true;

                obs.OnError(ex);

                return(new MyDisposable(() => { }));
            }).ToAsyncEnumerable();

            Assert.False(subscribed);

            var e = xs.GetEnumerator();

            Assert.True(subscribed);

            AssertThrows <Exception>(() => e.MoveNext().Wait(WaitTimeoutMs), ex_ => ((AggregateException)ex_).InnerExceptions.Single() == ex);
        }
Exemplo n.º 2
0
        public void ToAsyncEnumerable3()
        {
            var subscribed = false;

            var xs = new MyObservable <int>(obs =>
            {
                subscribed = true;

                obs.OnNext(42);
                obs.OnCompleted();

                return(new MyDisposable(() => { }));
            }).ToAsyncEnumerable();

            Assert.False(subscribed);

            var e = xs.GetEnumerator();

            Assert.True(subscribed);

            HasNext(e, 42);
            NoNext(e);
        }