public async Task HandleCancellation_ShouldCaptureContextWhenSpecified()
        {
            var context = new TestSynchronizationContext();

            SynchronizationContext.SetSynchronizationContext(context);

            await Task.Run(() => throw new OperationCanceledException())
            .HandleCancellationAsync(exception => { }, true)
            .ConfigureAwait(false);

            Assert.True(context.IsPostCalled);
        }
        public async Task SwallowCancellation_ShouldNotCaptureContext()
        {
            var context = new TestSynchronizationContext();

            SynchronizationContext.SetSynchronizationContext(context);

            await Task.Run(() => throw new OperationCanceledException())
            .SwallowCancellationAsync()
            .ConfigureAwait(false);

            Assert.False(context.IsPostCalled);
        }
        public async Task HandleException_ShouldNotCaptureContextByDefault()
        {
            var context = new TestSynchronizationContext();

            SynchronizationContext.SetSynchronizationContext(context);

            await Task.Run(() => throw new InvalidOperationException())
            .HandleExceptionAsync <InvalidOperationException>(exception => { })
            .ConfigureAwait(false);

            Assert.False(context.IsPostCalled);
        }