public void wait_while_paused_async_completes_immediately_if_not_paused()
 {
     var sut = new ExecutionContext();
     var completed = false;
     sut
         .WaitWhilePausedAsync()
         .Subscribe(_ => completed = true);
     Assert.True(completed);
 }
        public void wait_while_paused_async_waits_until_unpaused()
        {
            var sut = new ExecutionContext();
            sut.IsPaused = true;

            var executed = false;
            sut
                .WaitWhilePausedAsync()
                .Subscribe(_ => executed = true);

            Assert.False(executed);

            sut.IsPaused = false;

            Assert.True(executed);
        }
        public void wait_while_paused_async_cancels_if_the_context_is_cancelled()
        {
            var sut = new ExecutionContext();
            sut.IsPaused = true;

            var cancelled = false;
            sut
                .WaitWhilePausedAsync()
                .Catch<Unit, OperationCanceledException>(
                    _ =>
                    {
                        cancelled = true;
                        return Observable.Return(Unit.Default);
                    })
                .Subscribe();

            Assert.False(cancelled);

            sut.Cancel();

            Assert.True(cancelled);
        }