public void Fail_Multi_Error_Info()
        {
            var to = new TestObserver <int>();

            to.OnSubscribe(DisposableHelper.EMPTY);
            to.WithTag("Tag");

            try
            {
                to.AwaitDone(TimeSpan.FromMilliseconds(100));

                to.OnError(new NullReferenceException());

                to.OnError(new InvalidOperationException());

                to.AssertEmpty();

                Assert.Fail();
            }
            catch (Exception ex)
            {
                if (!ex.Message.StartsWith("Multiple errors"))
                {
                    throw ex;
                }
            }
        }
        public void Fail_Full_Info()
        {
            var to = new TestObserver <int>();

            to.OnSubscribe(DisposableHelper.EMPTY);
            to.WithTag("Tag");

            try
            {
                to.AwaitDone(TimeSpan.FromMilliseconds(100));

                to.OnCompleted();

                to.AssertEmpty();

                Assert.Fail();
            }
            catch (Exception ex)
            {
                if (!ex.Message.StartsWith("Unexpected"))
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 3
0
        public void Lazy_Dispose_Crash()
        {
            var to = new TestObserver <int>(requireOnSubscribe: true);

            ObservableSource.Using <int, int>(() => 1,
                                              _ => ObservableSource.Never <int>(),
                                              _ => throw new InvalidOperationException(), true)
            .Subscribe(to);

            to.Dispose();

            to.AssertEmpty();
        }
Exemplo n.º 4
0
        public void Complete_Dispose_Other()
        {
            var cs = new CompletableSubject();

            var to = new TestObserver <object>();

            cs.Subscribe(() => { to.Dispose(); });
            cs.Subscribe(to);

            cs.OnCompleted();

            to.AssertEmpty();
        }
        public void Error_Dispose_Other()
        {
            var ms = new SingleSubject <int>();

            var to1 = new TestObserver <int>();

            var count = 0;

            ms.Subscribe(v => { count = 1; }, e => { to1.Dispose(); });

            ms.Subscribe(to1);

            ms.OnError(new InvalidOperationException());

            to1.AssertEmpty();

            Assert.AreEqual(0, count);
        }
        public void Success_Dispose_Other()
        {
            var ms = new SingleSubject <int>();

            var to1 = new TestObserver <int>();

            var count = 0;

            ms.Subscribe(v => { to1.Dispose(); }, e => { count = 1; });

            ms.Subscribe(to1);

            ms.OnSuccess(1);

            to1.AssertEmpty();

            Assert.AreEqual(0, count);
        }
        public void Completed_Dispose_Other()
        {
            var ms = new MaybeSubject <int>();

            var to1 = new TestObserver <int>();

            var count = 0;

            ms.Subscribe(v => { count = 1; }, e => { count = 2; }, () => { to1.Dispose(); });

            ms.Subscribe(to1);

            ms.OnCompleted();

            to1.AssertEmpty();

            Assert.AreEqual(0, count);
        }