Esempio n. 1
0
        public void Error_Delayed()
        {
            var us1 = new UnicastSubject <int>();
            var us2 = new UnicastSubject <int>();

            var to = ReactiveExtensions.Zip(a =>
            {
                int s = 0;
                foreach (var v in a)
                {
                    s += v;
                }
                return(s);
            }, true,
                                            us1,
                                            us2
                                            ).Test();

            us1.EmitError(new InvalidOperationException(), 1, 2, 3);

            Assert.True(us2.HasObserver(), "us2: No observers!");

            us2.Emit(10, 20, 30, 40);

            Assert.False(us2.HasObserver(), "us2: Observers present!");

            to.AssertFailure(typeof(InvalidOperationException), 11, 22, 33);
        }
Esempio n. 2
0
        public void Mapper_Crashes()
        {
            var us1 = new UnicastSubject <int>();
            var us2 = new UnicastSubject <int>();

            var to = ReactiveExtensions.Zip(a =>
            {
                int s = 0;
                foreach (var v in a)
                {
                    s += v;
                }

                if (s == 33)
                {
                    throw new InvalidOperationException();
                }
                return(s);
            },
                                            us1,
                                            us2
                                            ).Test();

            us1.Emit(1, 2, 3);

            Assert.True(us1.HasObserver());
            Assert.True(us2.HasObserver());

            us2.Emit(10, 20, 30, 40);

            Assert.False(us1.HasObserver());
            Assert.False(us2.HasObserver());

            to.AssertFailure(typeof(InvalidOperationException), 11, 22);
        }
Esempio n. 3
0
 public void Second_Shorter()
 {
     ReactiveExtensions.Zip(a =>
     {
         int s = 0;
         foreach (var v in a)
         {
             s += v;
         }
         return(s);
     },
                            Observable.Range(1, 5),
                            Observable.Range(10, 4)
                            ).Test()
     .AssertResult(10 + 1, 11 + 2, 12 + 3, 13 + 4);
 }
Esempio n. 4
0
 public void Basic_DelayErrors()
 {
     ReactiveExtensions.Zip(a =>
     {
         int s = 0;
         foreach (var v in a)
         {
             s += v;
         }
         return(s);
     }, true,
                            Observable.Range(1, 5),
                            Observable.Range(10, 5)
                            ).Test()
     .AssertResult(10 + 1, 11 + 2, 12 + 3, 13 + 4, 14 + 5);
 }
Esempio n. 5
0
        public void Error_Second_Source()
        {
            var us1 = new UnicastSubject <int>();
            var us2 = new UnicastSubject <int>();

            var to = ReactiveExtensions.Zip(a =>
            {
                int s = 0;
                foreach (var v in a)
                {
                    s += v;
                }
                return(s);
            },
                                            us1,
                                            us2
                                            ).Test();

            us1.OnNext(1);

            to.AssertEmpty();

            us1.OnNext(2);

            to.AssertEmpty();

            us2.OnNext(10);

            to.AssertValuesOnly(11);

            us2.OnError(new InvalidOperationException());

            Assert.False(us1.HasObserver());

            to.AssertFailure(typeof(InvalidOperationException), 11);
        }