예제 #1
0
 public void Plain_Basic()
 {
     ObservableSource.FromTask <int>(Task.Factory.StartNew(() => { }))
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertResult();
 }
예제 #2
0
        public void Plain_Fused_Api()
        {
            var ttc = new TaskCompletionSource <int>();

            var src = ObservableSource.FromTask <int>((Task)ttc.Task);

            TestHelper.AssertFuseableApi(src);
        }
예제 #3
0
 public void Plain_Error()
 {
     ObservableSource.FromTask <int>(Task.Factory.StartNew(() => { throw new InvalidOperationException(); }))
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertFailure(typeof(AggregateException))
     .AssertCompositeError(typeof(InvalidOperationException));
 }
예제 #4
0
        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));
        }
예제 #5
0
        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();
        }
예제 #6
0
        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();
        }
예제 #7
0
        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);
        }