public void Plain_Basic() { ObservableSource.FromTask <int>(Task.Factory.StartNew(() => { })) .Test() .AwaitDone(TimeSpan.FromSeconds(5)) .AssertResult(); }
public void Plain_Fused_Api() { var ttc = new TaskCompletionSource <int>(); var src = ObservableSource.FromTask <int>((Task)ttc.Task); TestHelper.AssertFuseableApi(src); }
public void Plain_Error() { ObservableSource.FromTask <int>(Task.Factory.StartNew(() => { throw new InvalidOperationException(); })) .Test() .AwaitDone(TimeSpan.FromSeconds(5)) .AssertFailure(typeof(AggregateException)) .AssertCompositeError(typeof(InvalidOperationException)); }
public void Plain_Cancel() { var ttc = new TaskCompletionSource <int>(); var to = ObservableSource.FromTask <int>((Task)ttc.Task) .Test(); to.AssertEmpty(); Assert.True(ttc.TrySetCanceled()); to .AwaitDone(TimeSpan.FromSeconds(5)) .AssertFailure(typeof(OperationCanceledException)); }
public void Plain_Fused() { var ttc = new TaskCompletionSource <int>(); var to = ObservableSource.FromTask <int>((Task)ttc.Task) .Test(fusionMode: FusionSupport.Any) .AssertFuseable() .AssertFusionMode(FusionSupport.Async); to.AssertEmpty(); Assert.True(ttc.TrySetResult(default(int))); to.AwaitDone(TimeSpan.FromSeconds(5)) .AssertResult(); }
public void Plain_Dispose() { var ttc = new TaskCompletionSource <int>(); var to = ObservableSource.FromTask <int>((Task)ttc.Task) .Test(); to.AssertEmpty(); to.Dispose(); Assert.True(ttc.TrySetResult(0)); Thread.Sleep(100); to.AssertEmpty(); }
public void Value_Basic() { var count = 0; var source = ObservableSource.FromTask <int>(Task.Factory.StartNew(() => ++ count)); source .Test() .AwaitDone(TimeSpan.FromSeconds(5)) .AssertResult(1); source .Test() .AwaitDone(TimeSpan.FromSeconds(5)) .AssertResult(1); Assert.AreEqual(1, count); }