Skip to content

Commit

Permalink
fixed TestMultiplePauses test
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Dec 20, 2023
1 parent 9eca07d commit 04a38a1
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/Downloader.Test/UnitTests/PauseTokenTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Xunit;

namespace Downloader.Test.UnitTests;

public class PauseTokenTest
{
private PauseTokenSource _pauseTokenSource;
Expand Down Expand Up @@ -131,6 +132,7 @@ public async Task TestMultiplePauses()
// Pause the token source multiple times
_pauseTokenSource.Pause();
_pauseTokenSource.Pause();
_pauseTokenSource.Pause();

// Verify that a task is paused
Assert.True(_pauseTokenSource.IsPaused);
Expand All @@ -148,17 +150,8 @@ public async Task TestMultiplePauses()
// Resume the token source once
_pauseTokenSource.Resume();

// Wait for a short period of time to ensure that the task is still paused
await Task.Delay(100);
Assert.True(pauseTask.Status == TaskStatus.RanToCompletion);

// Resume the token source again
_pauseTokenSource.Resume();

// Wait for the task to complete
await pauseTask;

// Verify that the task completed successfully
Assert.True(pauseTask.Status == TaskStatus.RanToCompletion);
Assert.True(pauseTask.Status == TaskStatus.RanToCompletion, $"pauseTask status is: {pauseTask.Status}");
}
}
}

0 comments on commit 04a38a1

Please sign in to comment.