Пример #1
0
        public void Array_Error_First()
        {
            var count = 0;

            var src = MaybeSource.FromFunc(() =>
            {
                return(++count);
            });

            new[]
            {
                MaybeSource.Error <int>(new InvalidOperationException()),
                src
            }
            .Zip(Sum)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));

            Assert.AreEqual(0, count);
        }
Пример #2
0
        public void Enumerable_Error_Empty_First()
        {
            var count = 0;

            var src = MaybeSource.FromAction <int>(() =>
            {
                ++count;
            });

            new List <IMaybeSource <int> >()
            {
                MaybeSource.Error <int>(new InvalidOperationException()),
                src
            }
            .Zip(Sum)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));

            Assert.AreEqual(0, count);
        }
Пример #3
0
        public void Enumerable_Error_Second_Delayed()
        {
            var count = 0;

            var src = MaybeSource.FromFunc(() =>
            {
                return(++count);
            });

            new List <IMaybeSource <int> >()
            {
                src,
                MaybeSource.Error <int>(new InvalidOperationException())
            }
            .Zip(Sum, true)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));

            Assert.AreEqual(1, count);
        }
Пример #4
0
        public void Array_Error_Empty_Second_Delayed()
        {
            var count = 0;

            var src = MaybeSource.FromAction <int>(() =>
            {
                ++count;
            });

            new[]
            {
                src,
                MaybeSource.Error <int>(new InvalidOperationException())
            }
            .Zip(Sum, true)
            .Test()
            .AssertFailure(typeof(InvalidOperationException));

            Assert.AreEqual(1, count);
        }
        public void Limit_Error_Delay()
        {
            for (int i = 1; i < 10; i++)
            {
                var count = 0;

                var src = MaybeSource.FromFunc(() => ++ count);

                MaybeSource.ConcatEager(
                    new [] {
                    MaybeSource.Just(0),
                    MaybeSource.Error <int>(new InvalidOperationException()),
                    src
                }.ToObservable(), true, i
                    )
                .Test()
                .AssertFailure(typeof(InvalidOperationException), 0, 1);

                Assert.AreEqual(1, count);
            }
        }
Пример #6
0
 public void Action_Block_Error_Ignored()
 {
     MaybeSource.Error <int>(new InvalidOperationException())
     .BlockingSubscribe();
 }