File tree Expand file tree Collapse file tree 3 files changed +11
-10
lines changed
test/Soenneker.Utils.BackgroundQueue.Tests Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 1
- using System . Threading . Tasks ;
1
+ using System . Threading ;
2
+ using System . Threading . Tasks ;
2
3
using Soenneker . Tests . Unit ;
3
4
using Xunit ;
4
5
@@ -25,5 +26,5 @@ public interface IFixturedUnitTest : IAsyncLifetime
25
26
/// <summary>
26
27
/// Checks the background queue to see if it's empty, and loops until it is
27
28
/// </summary>
28
- ValueTask WaitOnQueueToEmpty ( ) ;
29
+ ValueTask WaitOnQueueToEmpty ( CancellationToken cancellationToken = default ) ;
29
30
}
Original file line number Diff line number Diff line change @@ -28,20 +28,20 @@ private async ValueTask TestValueTask()
28
28
[ Fact ]
29
29
public async Task WaitOnQueueToEmpty_should_complete_with_Task ( )
30
30
{
31
- await _util . QueueTask ( _ => TestTask ( ) ) ;
31
+ await _util . QueueTask ( _ => TestTask ( ) , CancellationToken ) ;
32
32
33
- await WaitOnQueueToEmpty ( ) ;
33
+ await WaitOnQueueToEmpty ( CancellationToken ) ;
34
34
35
- await Task . Delay ( 500 ) ;
35
+ await Task . Delay ( 500 , CancellationToken ) ;
36
36
}
37
37
38
38
[ Fact ]
39
39
public async Task WaitOnQueueToEmpty_should_complete_with_ValueTask ( )
40
40
{
41
- await _util . QueueValueTask ( _ => TestValueTask ( ) ) ;
41
+ await _util . QueueValueTask ( _ => TestValueTask ( ) , CancellationToken ) ;
42
42
43
- await WaitOnQueueToEmpty ( ) ;
43
+ await WaitOnQueueToEmpty ( CancellationToken ) ;
44
44
45
- await Task . Delay ( 500 ) ;
45
+ await Task . Delay ( 500 , CancellationToken ) ;
46
46
}
47
47
}
Original file line number Diff line number Diff line change @@ -71,15 +71,15 @@ public void CreateScope()
71
71
Scope = Fixture . ServiceProvider . CreateAsyncScope ( ) ;
72
72
}
73
73
74
- public async ValueTask WaitOnQueueToEmpty ( )
74
+ public async ValueTask WaitOnQueueToEmpty ( CancellationToken cancellationToken = default )
75
75
{
76
76
const int delayMs = 500 ;
77
77
78
78
bool isProcessing ;
79
79
80
80
do
81
81
{
82
- isProcessing = await _queueInformationUtil . Value . IsProcessing ( ) . NoSync ( ) ;
82
+ isProcessing = await _queueInformationUtil . Value . IsProcessing ( cancellationToken ) . NoSync ( ) ;
83
83
84
84
if ( isProcessing )
85
85
{
You can’t perform that action at this time.
0 commit comments