コード例 #1
0
        public void Observer_Dispose()
        {
            for (int i = 0; i < TestHelper.RACE_LOOPS; i++)
            {
                var cs = new MaybeSubject <int>();

                var to = new TestObserver <int>();

                var cdl = new CountdownEvent(1);

                Task.Factory.StartNew(() =>
                {
                    while (!cs.HasObserver())
                    {
                        ;
                    }
                    to.Dispose();
                    cdl.Signal();
                });

                cs.BlockingSubscribe(to);

                cdl.Wait();

                Assert.False(cs.HasObserver());
            }
        }
コード例 #2
0
        public void Observer_Complete_Async()
        {
            for (int i = 0; i < TestHelper.RACE_LOOPS; i++)
            {
                var cs = new MaybeSubject <int>();

                var to = new TestObserver <int>();

                var cdl = new CountdownEvent(1);

                Task.Factory.StartNew(() =>
                {
                    while (!cs.HasObserver())
                    {
                        ;
                    }
                    cs.OnCompleted();
                });

                cs.BlockingSubscribe(to);

                to.AssertResult();
            }
        }
コード例 #3
0
        public void Action_Error_Async()
        {
            for (int i = 0; i < TestHelper.RACE_LOOPS; i++)
            {
                var cs = new MaybeSubject <int>();

                var to = new TestObserver <int>();

                var cdl = new CountdownEvent(1);

                Task.Factory.StartNew(() =>
                {
                    while (!cs.HasObserver())
                    {
                        ;
                    }
                    cs.OnError(new InvalidOperationException());
                });

                cs.BlockingSubscribe(to.OnSuccess, to.OnError, to.OnCompleted);

                to.AssertFailure(typeof(InvalidOperationException));
            }
        }