Esempio n. 1
0
 public void Basic()
 {
     MaybeSource.Empty <int>()
     .OnTerminateDetach()
     .Test()
     .AssertResult();
 }
Esempio n. 2
0
 public void Eager_Empty()
 {
     Observable.Range(1, 5)
     .SwitchMap(v => MaybeSource.Empty <int>())
     .Test()
     .AssertResult();
 }
Esempio n. 3
0
 public void Basic_Empty_DelayErrors()
 {
     Observable.Range(1, 5)
     .ConcatMap(v => MaybeSource.Empty <int>(), true)
     .Test()
     .AssertResult();
 }
Esempio n. 4
0
 public void Maybes_Fallback_Empty()
 {
     MaybeSource.Empty <int>()
     .SwitchIfEmpty(MaybeSource.Empty <int>())
     .Test()
     .AssertResult();
 }
 public void Maybe_Next_Empty()
 {
     CompletableSource.Empty()
     .AndThen(MaybeSource.Empty <int>())
     .Test()
     .AssertResult();
 }
Esempio n. 6
0
 public void Maybes_Fallback_Null()
 {
     MaybeSource.Empty <int>()
     .SwitchIfEmpty(MaybeSource.Empty <int>(), null, MaybeSource.Empty <int>())
     .Test()
     .AssertError(typeof(NullReferenceException));
 }
Esempio n. 7
0
 public void Single_Error_Fallback()
 {
     MaybeSource.Empty <int>()
     .SwitchIfEmpty(SingleSource.Error <int>(new InvalidOperationException()))
     .Test()
     .AssertFailure(typeof(InvalidOperationException));
 }
Esempio n. 8
0
        public void Array_Limit_Null()
        {
            for (int i = 1; i < 10; i++)
            {
                var to = new IMaybeSource <int>[]
                {
                    MaybeSource.Just(1),
                    MaybeSource.Empty <int>(),
                    null
                }
                .ConcatEagerAll(maxConcurrency: i)
                .Test()
                .WithTag($"maxConcurrency={i}");

                if (i >= 3)
                {
                    // error cuts ahead
                    to.AssertFailure(typeof(NullReferenceException));
                }
                else
                {
                    to.AssertFailure(typeof(NullReferenceException), 1);
                }
            }
        }
Esempio n. 9
0
        public void Enumerable_Limit_Error()
        {
            for (int i = 1; i < 10; i++)
            {
                var to = new List <IMaybeSource <int> >()
                {
                    MaybeSource.Just(1),
                    MaybeSource.Empty <int>(),
                    MaybeSource.Error <int>(new InvalidOperationException())
                }
                .ConcatEager(maxConcurrency: i)
                .Test()
                .WithTag($"maxConcurrency={i}");

                if (i >= 3)
                {
                    // error cuts ahead
                    to.AssertFailure(typeof(InvalidOperationException));
                }
                else
                {
                    to.AssertFailure(typeof(InvalidOperationException), 1);
                }
            }
        }
        public void All_Empty()
        {
            var success        = 0;
            var afterSuccess   = 0;
            var completed      = 0;
            var error          = 0;
            var terminate      = 0;
            var afterterminate = 0;
            var subscribe      = 0;
            var dispose        = 0;
            var final          = 0;

            MaybeSource.Empty <int>()
            .DoOnSuccess(v => success++)
            .DoAfterSuccess(v => afterSuccess++)
            .DoOnCompleted(() => completed++)
            .DoOnError(e => error++)
            .DoOnTerminate(() => terminate++)
            .DoAfterTerminate(() => afterterminate++)
            .DoOnSubscribe(d => subscribe++)
            .DoOnDispose(() => dispose++)
            .DoFinally(() => final++)
            .Test()
            .AssertResult();

            Assert.AreEqual(0, success);
            Assert.AreEqual(0, afterSuccess);
            Assert.AreEqual(1, completed);
            Assert.AreEqual(0, error);
            Assert.AreEqual(1, terminate);
            Assert.AreEqual(1, afterterminate);
            Assert.AreEqual(1, subscribe);
            Assert.AreEqual(0, dispose);
            Assert.AreEqual(1, final);
        }
Esempio n. 11
0
 public void Empty()
 {
     MaybeSource.Empty <int>()
     .Filter(v => true)
     .Test()
     .AssertResult();
 }
Esempio n. 12
0
 public void Empty()
 {
     MaybeSource.Empty <int>()
     .Map(v => "" + (v + 1))
     .Test()
     .AssertResult();
 }
Esempio n. 13
0
 public void Empty()
 {
     MaybeSource.Empty <int>()
     .Timeout(TimeSpan.FromMinutes(1), NewThreadScheduler.Default)
     .Test()
     .AssertResult();
 }
Esempio n. 14
0
        public void Basic()
        {
            // do not make this var to ensure the target type is correct
            IObservable <int> o = MaybeSource.Empty <int>().ToObservable <int>();

            o.Test().AssertResult();
        }
Esempio n. 15
0
 public void Empty()
 {
     MaybeSource.Empty <int>()
     .FlatMap(v => Observable.Range(v, 5))
     .Test()
     .AssertResult();
 }
 public void Times_Empty()
 {
     MaybeSource.Empty <int>()
     .Retry()
     .Test()
     .AssertResult();
 }
Esempio n. 17
0
 public void Maybes_Fallback_Error()
 {
     MaybeSource.Empty <int>()
     .SwitchIfEmpty(MaybeSource.Error <int>(new InvalidOperationException()), MaybeSource.Just(2))
     .Test()
     .AssertError(typeof(InvalidOperationException));
 }
 public void Handler_Empty()
 {
     MaybeSource.Empty <int>()
     .Retry((e, i) => true)
     .Test()
     .AssertResult();
 }
Esempio n. 19
0
 public void Single_Empty()
 {
     MaybeSource.Empty <int>()
     .SwitchIfEmpty(SingleSource.Just(2))
     .Test()
     .AssertResult(2);
 }
Esempio n. 20
0
        public void Value_Basic()
        {
            var b = MaybeSource.Empty <int>()
                    .Wait(out var v);

            Assert.False(b);
        }
Esempio n. 21
0
 public void Maybes_Success()
 {
     MaybeSource.Just(1)
     .SwitchIfEmpty(MaybeSource.Empty <int>(), MaybeSource.Just(2))
     .Test()
     .AssertResult(1);
 }
Esempio n. 22
0
        public void Value_Basic_Timeout()
        {
            var b = MaybeSource.Empty <int>()
                    .Wait(out var v, 5000);

            Assert.False(b);
        }
Esempio n. 23
0
 public void Empty()
 {
     MaybeSource.Empty <int>()
     .OnErrorComplete()
     .Test()
     .AssertResult();
 }
Esempio n. 24
0
        public void Value_Basic_Timeout_CancellationTokenSource()
        {
            var b = MaybeSource.Empty <int>()
                    .Wait(out var v, 5000, cts: new CancellationTokenSource());

            Assert.False(b);
        }
Esempio n. 25
0
 public void Delayed_Empty()
 {
     Observable.Range(1, 5)
     .SwitchMap(v => MaybeSource.Empty <int>(), true)
     .Test()
     .AssertResult();
 }
        public void Empty()
        {
            ISingleSource <int> src = MaybeSource.Empty <int>()
                                      .ToSingle();

            src.Test().AssertFailure(typeof(IndexOutOfRangeException));
        }
Esempio n. 27
0
 public void Maybe_Completed()
 {
     MaybeSource.Empty <int>()
     .IgnoreElement()
     .Test()
     .AssertResult();
 }
 public void Empty()
 {
     MaybeSource.Empty <int>()
     .DefaultIfEmpty(2)
     .Test()
     .AssertResult(2);
 }
Esempio n. 29
0
 public void Basic_Empty()
 {
     Observable.Range(1, 5)
     .ConcatMap(v => MaybeSource.Empty <int>())
     .Test()
     .AssertResult();
 }
Esempio n. 30
0
 public void Complete()
 {
     MaybeSource.Empty <int>()
     .Hide()
     .Test()
     .AssertResult();
 }