Ejemplo n.º 1
0
 public void Predicate_Wrong_Error()
 {
     CompletableSource.Error(new InvalidOperationException())
     .Retry((e, i) => typeof(NotImplementedException).IsAssignableFrom(e.GetType()))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Ejemplo n.º 2
0
        public void Dispose()
        {
            var count = 0;
            var us    = new CompletableSubject();

            var to = CompletableSource.Defer(() =>
            {
                if (count++ < 5)
                {
                    return(CompletableSource.Error(new InvalidOperationException()));
                }
                return(us);
            })
                     .Retry()
                     .Test();

            to.AssertEmpty();

            Assert.True(us.HasObserver());

            to.Dispose();

            Assert.False(us.HasObserver());

            Assert.AreEqual(6, count);
        }
 public void Error()
 {
     CompletableSource.Error(new InvalidOperationException())
     .OnTerminateDetach()
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Ejemplo n.º 4
0
 public void Error_Inner()
 {
     Observable.Return(1)
     .SwitchMap(v => CompletableSource.Error(new InvalidOperationException()))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
 public void Handler_Errors()
 {
     CompletableSource.Error(new InvalidOperationException())
     .RetryWhen(v => v.Take(1).Skip(1).ConcatError(new NotImplementedException()))
     .Test()
     .AssertFailure(typeof(NotImplementedException));
 }
Ejemplo n.º 6
0
        public void All_Error()
        {
            var completed      = 0;
            var error          = 0;
            var terminate      = 0;
            var afterterminate = 0;
            var subscribe      = 0;
            var dispose        = 0;
            var final          = 0;

            CompletableSource.Error(new InvalidOperationException())
            .DoOnCompleted(() => completed++)
            .DoOnError(e => error++)
            .DoOnTerminate(() => terminate++)
            .DoAfterTerminate(() => afterterminate++)
            .DoOnSubscribe(d => subscribe++)
            .DoOnDispose(() => dispose++)
            .DoFinally(() => final++)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));

            Assert.AreEqual(0, completed);
            Assert.AreEqual(1, error);
            Assert.AreEqual(1, terminate);
            Assert.AreEqual(1, afterterminate);
            Assert.AreEqual(1, subscribe);
            Assert.AreEqual(0, dispose);
            Assert.AreEqual(1, final);
        }
 public void Error()
 {
     CompletableSource.Error(new InvalidOperationException())
     .Timeout(TimeSpan.FromMinutes(1), NewThreadScheduler.Default)
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
 public void Single_Inner_Error()
 {
     SingleSource.Just(1)
     .FlatMap(v => CompletableSource.Error(new InvalidOperationException()))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Ejemplo n.º 9
0
        public void Error()
        {
            // do not make this var to ensure the target type is correct
            IObservable <int> o = CompletableSource.Error(new InvalidOperationException()).ToObservable <int>();

            o.Test().AssertFailure(typeof(InvalidOperationException));
        }
 public void Handler_Completes()
 {
     CompletableSource.Error(new InvalidOperationException())
     .RetryWhen(v => v.Take(1).Skip(1))
     .Test()
     .AssertResult();
 }
Ejemplo n.º 11
0
 public void Error()
 {
     CompletableSource.Error(new InvalidOperationException())
     .OnErrorComplete()
     .Test()
     .AssertResult();
 }
        public void Error()
        {
            var count = 0;

            var us = new UnicastSubject <int>();

            var to = us
                     .ConcatMap(v => {
                if (v == 2)
                {
                    return(CompletableSource.Error(new InvalidOperationException()));
                }
                return(CompletableSource.FromAction(() => count++));
            })
                     .Test();

            to.AssertEmpty()
            .AssertSubscribed();

            us.OnNext(0);
            us.OnNext(1);
            us.OnNext(2);

            to.AssertFailure(typeof(InvalidOperationException));

            Assert.False(us.HasObserver());

            Assert.AreEqual(2, count);
        }
 public void Single_Main_Error()
 {
     CompletableSource.Error(new InvalidOperationException())
     .AndThen(SingleSource.Just(1))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Ejemplo n.º 14
0
        public void Race_Error()
        {
            var ex = new InvalidOperationException();

            for (int i = 0; i < TestHelper.RACE_LOOPS; i++)
            {
                var s = new Subject <ICompletableSource>();

                var cs1 = new CompletableSubject();


                var to = s
                         .SwitchMap(v => v)
                         .Test();

                TestHelper.Race(() =>
                {
                    cs1.OnCompleted();
                },
                                () =>
                {
                    s.OnNext(CompletableSource.Error(ex));
                    s.OnCompleted();
                }
                                );

                to.AssertFailure(typeof(InvalidOperationException));
            }
        }
 public void Error()
 {
     CompletableSource.Error(new InvalidOperationException())
     .ToSingle(1)
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
 public void Completable_Then_Error()
 {
     CompletableSource.Empty()
     .AndThen(CompletableSource.Error(new InvalidOperationException()))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Ejemplo n.º 17
0
 public void Fallback_Error()
 {
     CompletableSource.Error(new InvalidOperationException("main"))
     .OnErrorResumeNext(CompletableSource.Error(new InvalidOperationException("fallback")))
     .Test()
     .AssertFailure(typeof(InvalidOperationException))
     .AssertError(typeof(InvalidOperationException), "fallback");
 }
 public void Other_Delay_Error()
 {
     CompletableSource.Error(new NullReferenceException())
     .DelaySubscription(CompletableSource.Error(new InvalidOperationException()))
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertFailure(typeof(InvalidOperationException));
 }
Ejemplo n.º 19
0
 public void Error()
 {
     CompletableSource.Error(new InvalidOperationException())
     .Delay(TimeSpan.FromMilliseconds(100), NewThreadScheduler.Default)
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertFailure(typeof(InvalidOperationException));
 }
Ejemplo n.º 20
0
        public void Basic_Error()
        {
            var us = new UnicastSubject <int>();

            CompletableSource.Error(new InvalidOperationException())
            .RepeatWhen(v => us)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));
        }
Ejemplo n.º 21
0
        public void Observer_Error()
        {
            var to = new TestObserver <object>();

            CompletableSource.Error(new InvalidOperationException())
            .BlockingSubscribe(to);

            to.AssertFailure(typeof(InvalidOperationException));
        }
Ejemplo n.º 22
0
 public void Handler_Crash()
 {
     CompletableSource.Error(new InvalidOperationException("main"))
     .OnErrorResumeNext(e => { throw new InvalidOperationException("fallback"); })
     .Test()
     .AssertFailure(typeof(AggregateException))
     .AssertCompositeErrorCount(2)
     .AssertCompositeError(0, typeof(InvalidOperationException), "main")
     .AssertCompositeError(1, typeof(InvalidOperationException), "fallback");
 }
 public void Error_Cleanup_Crash_Non_Eager()
 {
     CompletableSource.Using(() => 1,
                             v => CompletableSource.Error(new NotImplementedException()),
                             v => { throw new InvalidOperationException(); },
                             false
                             )
     .Test()
     .AssertFailure(typeof(NotImplementedException));
 }
        public void Normal_Error()
        {
            var to = new TestObserver <object>();

            CompletableSource.Error(new InvalidOperationException())
            .SubscribeSafe(to);

            to.AssertSubscribed()
            .AssertFailure(typeof(InvalidOperationException));
        }
Ejemplo n.º 25
0
        public void Error()
        {
            var complete = 0;
            var error    = default(Exception);

            CompletableSource.Error(new InvalidOperationException())
            .Subscribe(() => complete++, e => error = e);

            Assert.AreEqual(0, complete);
            Assert.True(typeof(InvalidOperationException).IsAssignableFrom(error));
        }
 public void Error_Cleanup_Crash_Eager()
 {
     CompletableSource.Using(() => 1,
                             v => CompletableSource.Error(new NotImplementedException()),
                             v => { throw new InvalidOperationException(); }
                             )
     .Test()
     .AssertFailure(typeof(AggregateException))
     .AssertCompositeError(0, typeof(NotImplementedException))
     .AssertCompositeError(1, typeof(InvalidOperationException));
 }
Ejemplo n.º 27
0
        public void OnError_Basic()
        {
            var count = 0;

            CompletableSource.Error(new InvalidOperationException())
            .DoOnError(e => count++)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));

            Assert.AreEqual(1, count);
        }
Ejemplo n.º 28
0
        public void AfterTerminate_Error()
        {
            var count = 0;

            CompletableSource.Error(new InvalidOperationException())
            .DoAfterTerminate(() => count++)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));

            Assert.AreEqual(1, count);
        }
        public void Observable_Error()
        {
            var us = new UnicastSubject <int>();

            CompletableSource.Error(new InvalidOperationException())
            .AndThen(us)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));

            Assert.False(us.HasObserver());
        }
Ejemplo n.º 30
0
        public void Error()
        {
            var count = 0;
            var fb    = CompletableSource.FromAction(() => count++);

            CompletableSource.Error(new InvalidOperationException())
            .OnErrorResumeNext(fb)
            .Test()
            .AssertResult();

            Assert.AreEqual(1, count);
        }