public void PublishProcessor_Normal()
        {
            PublishProcessor <int> pp = new PublishProcessor <int>();

            var ts1 = pp.Test(0);
            var ts2 = pp.Test(0);

            ts1.AssertNoEvents();
            ts2.AssertNoValues();

            Flux.Range(1, 10).Subscribe(pp);

            ts1.AssertNoEvents();
            ts2.AssertNoValues();

            ts1.Request(1);

            ts1.AssertNoEvents();
            ts2.AssertNoValues();

            ts2.Request(10);

            ts1.AssertValues(1);
            ts2.AssertValues(1);

            ts1.Request(9);

            ts1.AssertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
            ts2.AssertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        }
        public void Backpressure()
        {
            var pp = new PublishProcessor <int>();

            pp.Start();

            var ts1 = pp.Test(20);

            pp.OnNext(1);
            pp.OnNext(2);

            ts1.AssertValues(1, 2);

            var ts2 = pp.Test(0);

            ts2.AssertValues();

            pp.OnNext(3);

            ts1.AssertValues(1, 2);
            ts2.AssertValues();

            ts2.Request(10);

            ts1.AssertValues(1, 2, 3);
            ts2.AssertValues(3);
        }
        public void Error2()
        {
            var pp = new PublishProcessor <int>();

            pp.Start();

            var ts1 = pp.Test();
            var ts2 = pp.Test();

            pp.OnNext(1);
            pp.OnError(new Exception());

            ts1.AssertFailure(typeof(Exception), 1);
            ts2.AssertFailure(typeof(Exception), 1);
        }
        public void Async()
        {
            var pp = new PublishProcessor <int>();

            pp.Start();

            Task.Factory.StartNew(() =>
            {
                while (!pp.HasSubscribers)
                {
                    Thread.Sleep(10);
                }
                for (int i = 0; i < 5; i++)
                {
                    while (!pp.Offer(i))
                    {
                        ;
                    }
                }
                pp.OnComplete();
            }, TaskCreationOptions.LongRunning);

            pp.Test().AwaitDone(TimeSpan.FromSeconds(5))
            .AssertResult(0, 1, 2, 3, 4);
        }
        public void Normal()
        {
            var dp = new PublishProcessor <int>();

            dp.Start();
            Assert.IsFalse(dp.HasSubscribers);

            var ts = dp.Test();

            Assert.IsTrue(dp.HasSubscribers);

            dp.OnNext(1);
            dp.OnNext(2);
            dp.OnNext(3);
            dp.OnNext(4);

            ts.AssertValues(1, 2, 3, 4);

            dp.OnComplete();

            ts.AssertResult(1, 2, 3, 4);
        }