public void AsyncReactiveSubjectBase_SubscribeAsync()
        {
            var s = new MyAsyncReactiveSubject <int>();

            var iv2    = default(IAsyncReactiveObserver <int>);
            var uri2   = default(Uri);
            var state2 = default(object);

            s.SubscribeImpl = async(o, u, x, ct) =>
            {
                iv2    = o;
                uri2   = u;
                state2 = x;

                await Task.Yield();

                return(null);
            };

            var iv    = new MyObserver <int>();
            var uri   = new Uri("foo://bar");
            var state = "qux";

            s.SubscribeAsync(iv, uri, state, CancellationToken.None).Wait();

            Assert.AreSame(iv, iv2);
            Assert.AreSame(uri, uri2);
            Assert.AreSame(state, state2);
        }
        public void AsyncReactiveSubjectBase_SubscribeAsync_ArgumentChecking()
        {
            var s = new MyAsyncReactiveSubject <int>();

            var iv    = new MyObserver <int>();
            var uri   = new Uri("foo://bar");
            var state = "qux";

            Assert.ThrowsException <ArgumentNullException>(() => s.SubscribeAsync(null, uri, state, CancellationToken.None));
            Assert.ThrowsException <ArgumentNullException>(() => s.SubscribeAsync(iv, null, state, CancellationToken.None));
        }
        public void AsyncReactiveSubjectBase_OnCompletedAsync()
        {
            var s = new MyAsyncReactiveSubject <int>();

            var done = false;

            s.OnCompletedImpl = async(ct) => { done = true; await Task.Yield(); };

            s.OnCompletedAsync().Wait();

            Assert.IsTrue(done);
        }
        public void AsyncReactiveSubjectBase_OnNextAsync()
        {
            var s = new MyAsyncReactiveSubject <int>();

            var y = 0;

            s.OnNextImpl = async(x, ct) => { y = x; await Task.Yield(); };

            s.OnNextAsync(42).Wait();

            Assert.AreEqual(42, y);
        }
        public void AsyncReactiveSubjectBase_OnErrorAsync()
        {
            var s = new MyAsyncReactiveSubject <int>();

            var err = default(Exception);

            s.OnErrorImpl = async(e, ct) => { err = e; await Task.Yield(); };

            var ex = new Exception();

            s.OnErrorAsync(ex).Wait();

            Assert.AreSame(ex, err);
        }
        public void AsyncReactiveSubjectBase_DisposeAsync()
        {
            var s = new MyAsyncReactiveSubject <int>();

            var disposed = false;

            s.DisposeImpl = async(ct) => { disposed = true; await Task.Yield(); };

#if NET5_0 || NETCOREAPP3_1
            s.DisposeAsync().AsTask().Wait();
#else
            s.DisposeAsync().Wait();
#endif

            Assert.IsTrue(disposed);
        }
        public void AsyncReactiveSubjectBase_OnErrorAsync_ArgumentChecking()
        {
            var s = new MyAsyncReactiveSubject <int>();

            Assert.ThrowsException <ArgumentNullException>(() => s.OnErrorAsync(null, CancellationToken.None));
        }