예제 #1
0
        public void OnOuterError()
        {
            var src1 = new Subject <int>();
            var src2 = new Subject <int>();
            var src3 = new Subject <int>();

            var src = new ListBehaviorSubject <IObservable <int> >();

            var list = new List <int>();

            Exception error = null;

            var sub = src.Switch().Subscribe(change => change.Apply(list), e => error = e);

            src.OnAdd(src1);
            src.OnAdd(src2);
            src.OnAdd(src3);

            var ex = new Exception("AAAAAAAaa");

            src.OnError(ex);

            Assert.AreEqual(ex, error);

            sub.Dispose();
        }
예제 #2
0
        public void OnInnerError()
        {
            var lbs1 = new ListBehaviorSubject <int>();

            lbs1.OnAdd(1);
            lbs1.OnAdd(2);

            var source = new BehaviorSubject <IObservableList <int> >(lbs1);

            var list = new List <int>();

            var       completed = false;
            Exception error     = null;

            var sub = source
                      .Switch()
                      .Subscribe(
                Observer.Create <ListChange <int> >(
                    change => change.Apply(list),
                    e => error      = e,
                    () => completed = true));

            var ex = new Exception("AAAAAA");

            lbs1.OnError(ex);

            Assert.AreEqual(ex, error);
            Assert.IsFalse(completed);

            sub.Dispose();
        }
예제 #3
0
        public void OnError()
        {
            var src = new ListBehaviorSubject <int>();

            var list = new List <int>();

            Exception error = null;

            var sub = src.Where(i => i > 2).Subscribe(change => change.Apply(list), e => error = e);

            Assert.IsNull(error);

            var ex = new Exception("AAa");

            src.OnError(ex);

            Assert.AreEqual(ex, error);

            sub.Dispose();
        }
예제 #4
0
        public void Replay_handles_errors()
        {
            var lbs = new ListBehaviorSubject <int>();

            lbs.OnAdd(1);

            var replay = lbs.Replay();

            lbs.OnAdd(2);

            var       list  = new List <int>();
            Exception error = null;
            var       sub   = replay.Subscribe(Observer.Create <ListChange <int> >(change => change.Apply(list), e => error = e));

            CollectionAssert.AreEqual(new int[] { }, list);

            var conn = replay.Connect();

            CollectionAssert.AreEqual(new[] { 1, 2 }, list);

            Assert.IsNull(error);

            var sourceError = new Exception("Actual");

            lbs.OnError(sourceError);

            Assert.AreEqual(sourceError, error);

            var       list2  = new List <int>();
            Exception error2 = null;
            var       sub2   = replay.Subscribe(Observer.Create <ListChange <int> >(change => change.Apply(list2), e => error2 = e));

            Assert.AreEqual(sourceError, error2);

            sub2.Dispose();
            sub.Dispose();
            conn.Dispose();
        }