public void Mapper_Crashes()
        {
            var us1 = new MonocastSubject <int>();
            var us2 = new MonocastSubject <int>();

            var to = ObservableSource.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);
        }
        public void Error_Delayed()
        {
            var us1 = new MonocastSubject <int>();
            var us2 = new MonocastSubject <int>();

            var to = ObservableSource.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);
        }
 public void Basic_DelayErrors_Fused()
 {
     ObservableSource.Zip(a =>
     {
         int s = 0;
         foreach (var v in a)
         {
             s += v;
         }
         return(s);
     }, true,
                          ObservableSource.Range(1, 5),
                          ObservableSource.Range(10, 5)
                          ).Test()
     .AssertResult(10 + 1, 11 + 2, 12 + 3, 13 + 4, 14 + 5);
 }
 public void Second_Shorter()
 {
     ObservableSource.Zip(a =>
     {
         int s = 0;
         foreach (var v in a)
         {
             s += v;
         }
         return(s);
     },
                          ObservableSource.Range(1, 5),
                          ObservableSource.Range(10, 4)
                          ).Test()
     .AssertResult(10 + 1, 11 + 2, 12 + 3, 13 + 4);
 }
 public void Basic()
 {
     ObservableSource.Zip(a =>
     {
         int s = 0;
         foreach (var v in a)
         {
             s += v;
         }
         return(s);
     },
                          ObservableSource.Range(1, 5).Hide(),
                          ObservableSource.Range(10, 5).Hide()
                          ).Test()
     .AssertResult(10 + 1, 11 + 2, 12 + 3, 13 + 4, 14 + 5);
 }
        public void Error_Second_Source()
        {
            var us1 = new MonocastSubject <int>();
            var us2 = new MonocastSubject <int>();

            var to = ObservableSource.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);
        }