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

                var s = ReactiveExtensions.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();
            }
        }
Beispiel #2
0
        public void Basic_With_Error()
        {
            var up = new UnicastSubject <int>();

            var to = new TestObserver <int>();

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

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

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

            var to = new TestObserver <int>();

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

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

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

                var s = ReactiveExtensions.ToSerialized(to);

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

                TestHelper.Race(emit, emit);

                to.AssertValueCount(1000);
            }
        }