public void Race() { for (int i = 0; i < TestHelper.RACE_LOOPS; i++) { var s = new Subject <ICompletableSource>(); var cs1 = new CompletableSubject(); var to = s .SwitchMap(v => v) .Test(); TestHelper.Race(() => { cs1.OnCompleted(); }, () => { s.OnNext(CompletableSource.Empty()); s.OnCompleted(); } ); to.AssertResult(); } }
public void Completed_Complete() { CompletableSource.Empty() .ToMaybe <int>() .Test() .AssertResult(); }
public void Single_Basic() { CompletableSource.Empty() .AndThen(SingleSource.Just(1)) .Test() .AssertResult(1); }
public void Completed_Success() { CompletableSource.Empty() .ToMaybe(1) .Test() .AssertResult(1); }
public void Single_Next_Error() { CompletableSource.Empty() .AndThen(SingleSource.Error <int>(new InvalidOperationException())) .Test() .AssertFailure(typeof(InvalidOperationException)); }
public void Dispose() { var count = 0; var us = new CompletableSubject(); var to = CompletableSource.Defer(() => { if (count++ < 5) { return(CompletableSource.Empty()); } return(us); }) .Repeat() .Test(); to.AssertEmpty(); Assert.True(us.HasObserver()); to.Dispose(); Assert.False(us.HasObserver()); Assert.AreEqual(6, count); }
public void Basic() { CompletableSource.Empty() .OnErrorComplete() .Test() .AssertResult(); }
public void Maybe_Next_Empty() { CompletableSource.Empty() .AndThen(MaybeSource.Empty <int>()) .Test() .AssertResult(); }
public void Predicate_Crash() { CompletableSource.Empty() .Repeat(times => { throw new InvalidOperationException(); }) .Test() .AssertFailure(typeof(InvalidOperationException)); }
public void Completed() { CompletableSource.Empty() .ToSingle(1) .Test() .AssertResult(1); }
public void Basic() { // do not make this var to ensure the target type is correct IObservable <int> o = CompletableSource.Empty().ToObservable <int>(); o.Test().AssertResult(); }
public void All_Basic() { var completed = 0; var error = 0; var terminate = 0; var afterterminate = 0; var subscribe = 0; var dispose = 0; var final = 0; CompletableSource.Empty() .DoOnCompleted(() => completed++) .DoOnError(e => error++) .DoOnTerminate(() => terminate++) .DoAfterTerminate(() => afterterminate++) .DoOnSubscribe(d => subscribe++) .DoOnDispose(() => dispose++) .DoFinally(() => final++) .Test() .AssertResult(); 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 Single_Just() { SingleSource.Just(1) .FlatMap(v => CompletableSource.Empty()) .Test() .AssertResult(); }
public void Predicate() { CompletableSource.Empty() .Retry((e, c) => true) .Test() .AssertResult(); }
public void Basic_Finite() { CompletableSource.Empty() .Retry(5) .Test() .AssertResult(); }
public void Basic() { CompletableSource.Empty() .OnTerminateDetach() .Test() .AssertResult(); }
public void Basic() { CompletableSource.Empty() .Timeout(TimeSpan.FromMinutes(1), NewThreadScheduler.Default) .Test() .AssertResult(); }
public void Observable_Then_Error() { CompletableSource.Empty() .AndThen(Observable.Throw <int>(new InvalidOperationException())) .Test() .AssertFailure(typeof(InvalidOperationException)); }
public void Observable_Basic() { CompletableSource.Empty() .AndThen(Observable.Range(1, 5)) .Test() .AssertResult(1, 2, 3, 4, 5); }
public void Basic() { CompletableSource.Empty() .Delay(TimeSpan.FromMilliseconds(100), NewThreadScheduler.Default) .Test() .AwaitDone(TimeSpan.FromSeconds(5)) .AssertResult(); }
public void Basic() { Assert.True( CompletableSource.Empty() .ToTask() .Wait(5000) ); }
public void Action_Basic() { var to = new TestObserver <object>(); CompletableSource.Empty() .BlockingSubscribe(to.OnCompleted, to.OnError); to.AssertResult(); }
public void Basic_Complete() { var complete = 0; CompletableSource.Empty() .Subscribe(() => complete++); Assert.AreEqual(1, complete); }
public void Observer_Basic() { var to = new TestObserver <object>(); CompletableSource.Empty() .BlockingSubscribe(to); to.AssertResult(); }
public void Completed_Cleanup_Crash_Eager() { CompletableSource.Using(() => 1, v => CompletableSource.Empty(), v => { throw new InvalidOperationException(); } ) .Test() .AssertFailure(typeof(InvalidOperationException)); }
public void OnCompleted_Crash() { var error = default(Exception); CompletableSource.Empty() .Subscribe(() => throw new InvalidOperationException(), e => error = e); Assert.Null(error); }
public void Normal_Complete() { var to = new TestObserver <object>(); CompletableSource.Empty() .SubscribeSafe(to); to.AssertSubscribed() .AssertResult(); }
public void Completed_Cleanup_Crash_Non_Eager() { CompletableSource.Using(() => 1, v => CompletableSource.Empty(), v => { throw new InvalidOperationException(); }, false ) .Test() .AssertResult(); }
public void Basic_Token() { var cts = new CancellationTokenSource(); Assert.True( CompletableSource.Empty() .ToTask(cts) .Wait(5000) ); }
public void AfterTerminate_Basic() { var count = 0; CompletableSource.Empty() .DoAfterTerminate(() => count++) .Test() .AssertResult(); Assert.AreEqual(1, count); }