From 04a38a1180684520f4cec8846101c929da981710 Mon Sep 17 00:00:00 2001 From: bezzad Date: Wed, 20 Dec 2023 16:50:16 +0330 Subject: [PATCH] fixed TestMultiplePauses test --- src/Downloader.Test/UnitTests/PauseTokenTest.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Downloader.Test/UnitTests/PauseTokenTest.cs b/src/Downloader.Test/UnitTests/PauseTokenTest.cs index f046271..3901506 100644 --- a/src/Downloader.Test/UnitTests/PauseTokenTest.cs +++ b/src/Downloader.Test/UnitTests/PauseTokenTest.cs @@ -3,6 +3,7 @@ using Xunit; namespace Downloader.Test.UnitTests; + public class PauseTokenTest { private PauseTokenSource _pauseTokenSource; @@ -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); @@ -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}"); } -} +} \ No newline at end of file