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

                var s = ObservableSource.ToSerialized(to);

                var ex = new InvalidOperationException();

                Action emit = () => {
                    for (int j = 0; j < 500; j++)
                    {
                        s.OnNext(j);
                    }
                };

                Action complete = () =>
                {
                    for (int j = 0; j < 250; j++)
                    {
                        s.OnNext(j);
                    }

                    s.OnError(ex);
                };

                TestHelper.Race(emit, complete);

                Assert.True(to.ItemCount >= 250);

                to.AssertError(typeof(InvalidOperationException))
                .AssertNotCompleted();
            }
        }
コード例 #2
0
        public void Basic_With_Error()
        {
            var up = new MonocastSubject <int>();

            var to = new TestObserver <int>();

            up.Subscribe(ObservableSource.ToSerialized(to));

            up.EmitError(new InvalidOperationException(), 1, 2, 3, 4, 5);

            to.AssertFailure(typeof(InvalidOperationException), 1, 2, 3, 4, 5);
        }
コード例 #3
0
        public void Basic()
        {
            var up = new MonocastSubject <int>();

            var to = new TestObserver <int>();

            up.Subscribe(ObservableSource.ToSerialized(to));

            up.EmitAll(1, 2, 3, 4, 5);

            to.AssertResult(1, 2, 3, 4, 5);
        }
コード例 #4
0
        public void OnNext_Race()
        {
            for (int i = 0; i < TestHelper.RACE_LOOPS; i++)
            {
                var to = new TestObserver <int>();

                var s = ObservableSource.ToSerialized(to);

                Action emit = () => {
                    for (int j = 0; j < 500; j++)
                    {
                        s.OnNext(j);
                    }
                };

                TestHelper.Race(emit, emit);

                to.AssertValueCount(1000);
            }
        }