From 96976efec311a5e8a0e7888b5caa6d0ba3043cbf Mon Sep 17 00:00:00 2001 From: Jacob Lauzon Date: Thu, 9 Jan 2025 12:04:59 -0800 Subject: [PATCH] Remove sync WaitForCompletion --- .../src/TransferOperation.cs | 16 +-- .../tests/Shared/StartTransferCopyTestBase.cs | 113 ----------------- .../StartTransferDirectoryCopyTestBase.cs | 110 +--------------- .../StartTransferDirectoryDownloadTestBase.cs | 120 +----------------- .../Shared/StartTransferDownloadTestBase.cs | 106 ---------------- .../tests/Shared/TestTransferWithTimeout.cs | 16 --- .../tests/TransferOperationTests.cs | 35 ----- 7 files changed, 7 insertions(+), 509 deletions(-) diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferOperation.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferOperation.cs index 3239ef106568..0ce202459234 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferOperation.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferOperation.cs @@ -61,17 +61,7 @@ internal TransferOperation( } /// - /// Ensures completion of the TransferOperation and attempts to get result - /// - public void WaitForCompletion(CancellationToken cancellationToken = default) - { -#pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead. - WaitForCompletionAsync(cancellationToken).GetAwaiter().GetResult(); -#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead. - } - - /// - /// Waits until the data transfer itself has completed + /// Waits until the transfer has completed. /// /// public async Task WaitForCompletionAsync(CancellationToken cancellationToken = default) @@ -80,11 +70,11 @@ public async Task WaitForCompletionAsync(CancellationToken cancellationToken = d } /// - /// Attempts to pause the current Data Transfer. + /// Attempts to pause the current transfer. /// /// /// - /// Will return false if the data transfer has already been completed. + /// Will return false if the transfer has already been completed. /// /// Will return true if the pause has taken place. /// diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferCopyTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferCopyTestBase.cs index d7ed7132b057..96f72d3f5a3c 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferCopyTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferCopyTestBase.cs @@ -832,119 +832,6 @@ await TestTransferWithTimeout.WaitForCompletionAsync( Assert.AreEqual(true, transfer.Status.HasSkippedItems); } - [RecordedTest] - public async Task StartTransfer_EnsureCompleted() - { - // Arrange - await using IDisposingContainer source = await GetSourceDisposingContainerAsync(); - await using IDisposingContainer destination = await GetDestinationDisposingContainerAsync(); - - TransferOptions options = new TransferOptions(); - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - // Create transfer to do a EnsureCompleted - TransferOperation transfer = await CreateStartTransfer( - source.Container, - destination.Container, - concurrency: 1, - options: options); - - // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - await testEventsRaised.AssertSingleCompletedCheck(); - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - } - - [RecordedTest] - public async Task StartTransfer_EnsureCompleted_Failed() - { - // Arrange - await using IDisposingContainer source = await GetSourceDisposingContainerAsync(); - await using IDisposingContainer destination = await GetDestinationDisposingContainerAsync(); - - TransferOptions options = new TransferOptions() - { - CreationPreference = StorageResourceCreationPreference.FailIfExists - }; - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - // Create transfer to do a AwaitCompletion - TransferOperation transfer = await CreateStartTransfer( - source.Container, - destination.Container, - concurrency: 1, - createFailedCondition: true, - options: options); - - // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - await testEventsRaised.AssertSingleFailedCheck(1); - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - Assert.AreEqual(true, transfer.Status.HasFailedItems); - var testException = testEventsRaised.FailedEvents.First().Exception; - if (testException is RequestFailedException rfe) - { - Assert.That(rfe.ErrorCode, Does.Contain(_expectedOverwriteExceptionMessage)); - } - else - { - Assert.IsTrue(testException.Message.Contains(_expectedOverwriteExceptionMessage)); - } - } - - [RecordedTest] - public async Task StartTransfer_EnsureCompleted_Skipped() - { - // Arrange - await using IDisposingContainer source = await GetSourceDisposingContainerAsync(); - await using IDisposingContainer destination = await GetDestinationDisposingContainerAsync(); - - // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() - { - CreationPreference = StorageResourceCreationPreference.SkipIfExists - }; - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - // Create transfer to do a EnsureCompleted - TransferOperation transfer = await CreateStartTransfer( - source.Container, - destination.Container, - concurrency: 1, - createFailedCondition: true, - options: options); - - // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - await testEventsRaised.AssertSingleSkippedCheck(); - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - Assert.AreEqual(true, transfer.Status.HasSkippedItems); - } - private async Task CopyRemoteObjects_VerifyProperties( TSourceContainerClient sourceContainer, TDestinationContainerClient destinationContainer, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryCopyTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryCopyTestBase.cs index 0f586370e138..f920194d219b 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryCopyTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryCopyTestBase.cs @@ -793,115 +793,9 @@ await TestTransferWithTimeout.WaitForCompletionAsync( await testEventsRaised.AssertContainerCompletedWithSkippedCheck(1); } - [RecordedTest] - public async Task StartTransfer_EnsureCompleted() - { - // Arrange - await using IDisposingContainer source = await GetSourceDisposingContainerAsync(); - await using IDisposingContainer destination = await GetDestinationDisposingContainerAsync(); - - // Create transfer to do a EnsureCompleted - TransferOptions options = new TransferOptions(); - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - TransferOperation transfer = await CreateStartTransfer( - source.Container, - destination.Container, - 1, - options: options); - - // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - testEventsRaised.AssertUnexpectedFailureCheck(); - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - } - [Test] [LiveOnly] // https://github.com/Azure/azure-sdk-for-net/issues/46717 - public async Task StartTransfer_EnsureCompleted_Failed() - { - // Arrange - await using IDisposingContainer source = await GetSourceDisposingContainerAsync(); - await using IDisposingContainer destination = await GetDestinationDisposingContainerAsync(); - - TransferOptions options = new TransferOptions() - { - CreationPreference = StorageResourceCreationPreference.FailIfExists - }; - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - // Create transfer to do a AwaitCompletion - TransferOperation transfer = await CreateStartTransfer( - source.Container, - destination.Container, - 1, - createFailedCondition: true, - options: options); - - // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - Assert.AreEqual(true, transfer.Status.HasFailedItems); - await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); - Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains(_expectedOverwriteExceptionMessage)); - } - - [RecordedTest] - public async Task StartTransfer_EnsureCompleted_Skipped() - { - // Arrange - await using IDisposingContainer source = await GetSourceDisposingContainerAsync(); - await using IDisposingContainer destination = await GetDestinationDisposingContainerAsync(); - - // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() - { - CreationPreference = StorageResourceCreationPreference.SkipIfExists - }; - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - // Create transfer to do a EnsureCompleted - TransferOperation transfer = await CreateStartTransfer( - source.Container, - destination.Container, - 1, - createFailedCondition: true, - options: options); - - // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - testEventsRaised.AssertUnexpectedFailureCheck(); - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - Assert.AreEqual(true, transfer.Status.HasSkippedItems); - } - - [Test] - [LiveOnly] // https://github.com/Azure/azure-sdk-for-net/issues/46717 - public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() + public async Task StartTransfer_AwaitCompletion_Failed_SmallChunks() { // Arrange await using IDisposingContainer source = await GetSourceDisposingContainerAsync(); @@ -926,7 +820,7 @@ public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - TestTransferWithTimeout.WaitForCompletion( + await TestTransferWithTimeout.WaitForCompletionAsync( transfer, testEventsRaised, cancellationTokenSource.Token); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryDownloadTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryDownloadTestBase.cs index 6440ecbd3914..85d52912bace 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryDownloadTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryDownloadTestBase.cs @@ -557,125 +557,9 @@ await TestTransferWithTimeout.WaitForCompletionAsync( await testEventsRaised.AssertContainerCompletedWithSkippedCheck(1); } - [Test] - public async Task StartTransfer_EnsureCompleted() - { - // Arrange - await using IDisposingContainer test = await GetDisposingContainerAsync(); - using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - - // Create transfer to do a EnsureCompleted - TransferOptions options = new TransferOptions(); - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - TransferOperation transfer = await CreateStartTransfer( - test.Container, - destinationFolder, - 1, - options: options, - cancellationToken: cancellationTokenSource.Token); - - // Act - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - await testEventsRaised.AssertContainerCompletedCheck(4); - } - [Test] [LiveOnly] // https://github.com/Azure/azure-sdk-for-net/issues/46717 - public async Task StartTransfer_EnsureCompleted_Failed() - { - // Arrange - await using IDisposingContainer test = await GetDisposingContainerAsync(); - using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - - TransferOptions options = new TransferOptions() - { - CreationPreference = StorageResourceCreationPreference.FailIfExists - }; - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - // Create at least one of the dest files to make it fail - File.Create(string.Join("/", destinationFolder, _firstItemName)).Close(); - - // Create transfer to do a AwaitCompletion - TransferOperation transfer = await CreateStartTransfer( - test.Container, - destinationFolder, - 1, - options: options, - cancellationToken: cancellationTokenSource.Token); - - // Act - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - Assert.AreEqual(true, transfer.Status.HasFailedItems); - Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains(_expectedOverwriteExceptionMessage)); - await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); - } - - [Test] - public async Task StartTransfer_EnsureCompleted_Skipped() - { - // Arrange - await using IDisposingContainer test = await GetDisposingContainerAsync(); - using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - - // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() - { - CreationPreference = StorageResourceCreationPreference.SkipIfExists - }; - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - // Create at least one of the dest files to make it fail - File.Create(string.Join("/", destinationFolder, _firstItemName)).Close(); - - // Create transfer to do a EnsureCompleted - TransferOperation transfer = await CreateStartTransfer( - test.Container, - destinationFolder, - 1, - options: options, - cancellationToken: cancellationTokenSource.Token); - - // Act - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - Assert.AreEqual(true, transfer.Status.HasSkippedItems); - await testEventsRaised.AssertContainerCompletedWithSkippedCheck(1); - } - - [Test] - [LiveOnly] // https://github.com/Azure/azure-sdk-for-net/issues/46717 - public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() + public async Task StartTransfer_AwaitCompletion_Failed_SmallChunks() { // Arrange await using IDisposingContainer test = await GetDisposingContainerAsync(); @@ -704,7 +588,7 @@ public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() cancellationToken: cancellationTokenSource.Token); // Act - TestTransferWithTimeout.WaitForCompletion( + await TestTransferWithTimeout.WaitForCompletionAsync( transfer, testEventsRaised, cancellationTokenSource.Token); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDownloadTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDownloadTestBase.cs index 8fc4d059bef8..a44a8ec1badb 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDownloadTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDownloadTestBase.cs @@ -261,112 +261,6 @@ await TestTransferWithTimeout.WaitForCompletionAsync( await testEventRaised.AssertSingleSkippedCheck(); } - [RecordedTest] - public async Task StartTransfer_EnsureCompleted() - { - // Arrange - await using IDisposingContainer test = await GetDisposingContainerAsync(); - using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - - // Create transfer to do a EnsureCompleted - TransferOptions options = new TransferOptions() - { - CreationPreference = StorageResourceCreationPreference.FailIfExists - }; - TestEventsRaised testEventRaised = new TestEventsRaised(options); - - // Create transfer to do a AwaitCompletion - TransferOperation transfer = await CreateStartTransfer( - containerClient: test.Container, - localDirectoryPath: testDirectory.DirectoryPath, - concurrency: 1, - options: options); - - // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.WaitForCompletion(cancellationTokenSource.Token); - - // Assert - testEventRaised.AssertUnexpectedFailureCheck(); - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - } - - [RecordedTest] - public async Task StartTransfer_EnsureCompleted_Failed() - { - // Arrange - await using IDisposingContainer test = await GetDisposingContainerAsync(); - using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - - TransferOptions options = new TransferOptions() - { - CreationPreference = StorageResourceCreationPreference.FailIfExists - }; - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - // Create transfer to do a AwaitCompletion - TransferOperation transfer = await CreateStartTransfer( - containerClient: test.Container, - localDirectoryPath: testDirectory.DirectoryPath, - concurrency: 1, - createFailedCondition: true, - options: options); - - // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - Assert.AreEqual(true, transfer.Status.HasFailedItems); - await testEventsRaised.AssertSingleFailedCheck(1); - Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains(_expectedOverwriteExceptionMessage)); - } - - [RecordedTest] - public async Task StartTransfer_EnsureCompleted_Skipped() - { - // Arrange - await using IDisposingContainer test = await GetDisposingContainerAsync(); - using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - - // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() - { - CreationPreference = StorageResourceCreationPreference.SkipIfExists - }; - TestEventsRaised testEventsRaised = new TestEventsRaised(options); - - // Create transfer to do a EnsureCompleted - TransferOperation transfer = await CreateStartTransfer( - containerClient: test.Container, - localDirectoryPath: testDirectory.DirectoryPath, - concurrency: 1, - createFailedCondition: true, - options: options); - - // Act - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - TestTransferWithTimeout.WaitForCompletion( - transfer, - testEventsRaised, - cancellationTokenSource.Token); - - // Assert - await testEventsRaised.AssertSingleSkippedCheck(); - Assert.NotNull(transfer); - Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(TransferState.Completed, transfer.Status.State); - Assert.AreEqual(true, transfer.Status.HasSkippedItems); - } - internal class VerifyDownloadObjectContentInfo { public readonly TObjectClient SourceObjectClient; diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestTransferWithTimeout.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestTransferWithTimeout.cs index afa6e049c8be..35ab0d58dd31 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestTransferWithTimeout.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestTransferWithTimeout.cs @@ -10,22 +10,6 @@ namespace Azure.Storage.DataMovement.Tests { public static class TestTransferWithTimeout { - public static void WaitForCompletion( - TransferOperation transferOperation, - TestEventsRaised testEventsRaised, - CancellationToken cancellationToken = default) - { - try - { - transferOperation.WaitForCompletion(cancellationToken); - } - catch (Exception ex) - when (ex is OperationCanceledException || ex is TaskCanceledException) - { - PrintAllEvents(testEventsRaised); - } - } - public static async Task WaitForCompletionAsync( TransferOperation transferOperation, TestEventsRaised testEventsRaised, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/TransferOperationTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/TransferOperationTests.cs index 56d21ccb8525..32ffbab6c346 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/TransferOperationTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/TransferOperationTests.cs @@ -76,41 +76,6 @@ public void HasCompleted_True( Assert.IsTrue(transfer.HasCompleted); } - [Test] - public void EnsureCompleted() - { - // Arrange - string transferId = GetNewTransferId(); - - TransferOperation transfer = new TransferOperation( - id: transferId, - status: SuccessfulCompletedStatus); - - // Act - transfer.WaitForCompletion(); - - // Assert - Assert.AreEqual(transferId, transfer.Id); - Assert.IsTrue(transfer.HasCompleted); - } - - [Test] - public void EnsureCompleted_CancellationToken() - { - // Arrange - string transferId = GetNewTransferId(); - - TransferOperation transfer = new TransferOperation( - id: transferId, - status: QueuedStatus); - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(1)); - - // Act - TestHelper.AssertExpectedException( - () => transfer.WaitForCompletion(cancellationTokenSource.Token), - new OperationCanceledException("The operation was canceled.")); - } - [Test] public async Task AwaitCompletion() {