public void Basic() { MaybeSource.Empty <int>() .OnTerminateDetach() .Test() .AssertResult(); }
public void Eager_Empty() { Observable.Range(1, 5) .SwitchMap(v => MaybeSource.Empty <int>()) .Test() .AssertResult(); }
public void Basic_Empty_DelayErrors() { Observable.Range(1, 5) .ConcatMap(v => MaybeSource.Empty <int>(), true) .Test() .AssertResult(); }
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(); }
public void Maybes_Fallback_Null() { MaybeSource.Empty <int>() .SwitchIfEmpty(MaybeSource.Empty <int>(), null, MaybeSource.Empty <int>()) .Test() .AssertError(typeof(NullReferenceException)); }
public void Single_Error_Fallback() { MaybeSource.Empty <int>() .SwitchIfEmpty(SingleSource.Error <int>(new InvalidOperationException())) .Test() .AssertFailure(typeof(InvalidOperationException)); }
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); } } }
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); }
public void Empty() { MaybeSource.Empty <int>() .Filter(v => true) .Test() .AssertResult(); }
public void Empty() { MaybeSource.Empty <int>() .Map(v => "" + (v + 1)) .Test() .AssertResult(); }
public void Empty() { MaybeSource.Empty <int>() .Timeout(TimeSpan.FromMinutes(1), NewThreadScheduler.Default) .Test() .AssertResult(); }
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(); }
public void Empty() { MaybeSource.Empty <int>() .FlatMap(v => Observable.Range(v, 5)) .Test() .AssertResult(); }
public void Times_Empty() { MaybeSource.Empty <int>() .Retry() .Test() .AssertResult(); }
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(); }
public void Single_Empty() { MaybeSource.Empty <int>() .SwitchIfEmpty(SingleSource.Just(2)) .Test() .AssertResult(2); }
public void Value_Basic() { var b = MaybeSource.Empty <int>() .Wait(out var v); Assert.False(b); }
public void Maybes_Success() { MaybeSource.Just(1) .SwitchIfEmpty(MaybeSource.Empty <int>(), MaybeSource.Just(2)) .Test() .AssertResult(1); }
public void Value_Basic_Timeout() { var b = MaybeSource.Empty <int>() .Wait(out var v, 5000); Assert.False(b); }
public void Empty() { MaybeSource.Empty <int>() .OnErrorComplete() .Test() .AssertResult(); }
public void Value_Basic_Timeout_CancellationTokenSource() { var b = MaybeSource.Empty <int>() .Wait(out var v, 5000, cts: new CancellationTokenSource()); Assert.False(b); }
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)); }
public void Maybe_Completed() { MaybeSource.Empty <int>() .IgnoreElement() .Test() .AssertResult(); }
public void Empty() { MaybeSource.Empty <int>() .DefaultIfEmpty(2) .Test() .AssertResult(2); }
public void Basic_Empty() { Observable.Range(1, 5) .ConcatMap(v => MaybeSource.Empty <int>()) .Test() .AssertResult(); }
public void Complete() { MaybeSource.Empty <int>() .Hide() .Test() .AssertResult(); }