1
- // Copyright (c) .NET Foundation. All rights reserved.
1
+ // Copyright (c) .NET Foundation. All rights reserved.
2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
4
using System ;
@@ -145,7 +145,7 @@ public async Task StopAsync_CancelsExecution()
145
145
await service . StopAsync ( ) ; // Trigger cancellation
146
146
147
147
// Assert
148
- await AssertCancelledAsync ( publishers [ 0 ] . Entries [ 0 ] . cancellationToken ) ;
148
+ await AssertCanceledAsync ( publishers [ 0 ] . Entries [ 0 ] . cancellationToken ) ;
149
149
Assert . False ( service . IsTimerRunning ) ;
150
150
Assert . True ( service . IsStopping ) ;
151
151
@@ -286,10 +286,7 @@ public async Task RunAsync_PublishersCanTimeout()
286
286
new TestPublisher ( ) { Wait = unblock . Task , } ,
287
287
} ;
288
288
289
- var service = CreateService ( publishers , sink : sink , configure : ( options ) =>
290
- {
291
- options . Timeout = TimeSpan . FromMilliseconds ( 50 ) ;
292
- } ) ;
289
+ var service = CreateService ( publishers , sink : sink ) ;
293
290
294
291
try
295
292
{
@@ -300,7 +297,9 @@ public async Task RunAsync_PublishersCanTimeout()
300
297
301
298
await publishers [ 0 ] . Started . TimeoutAfter ( TimeSpan . FromSeconds ( 10 ) ) ;
302
299
303
- await AssertCancelledAsync ( publishers [ 0 ] . Entries [ 0 ] . cancellationToken ) ;
300
+ service . CancelToken ( ) ;
301
+
302
+ await AssertCanceledAsync ( publishers [ 0 ] . Entries [ 0 ] . cancellationToken ) ;
304
303
305
304
unblock . SetResult ( null ) ;
306
305
@@ -483,7 +482,7 @@ private HealthCheckPublisherHostedService CreateService(
483
482
return services . GetServices < IHostedService > ( ) . OfType < HealthCheckPublisherHostedService > ( ) . Single ( ) ;
484
483
}
485
484
486
- private static async Task AssertCancelledAsync ( CancellationToken cancellationToken )
485
+ private static async Task AssertCanceledAsync ( CancellationToken cancellationToken )
487
486
{
488
487
await Assert . ThrowsAsync < TaskCanceledException > ( ( ) => Task . Delay ( TimeSpan . FromSeconds ( 10 ) , cancellationToken ) ) ;
489
488
}
0 commit comments