@@ -300,8 +300,15 @@ public static async Task TestAppOfflineDebounceTime(string fileName, int delayIn
300
300
WatchFiles = { "host.json" }
301
301
} ;
302
302
var loggerFactory = new LoggerFactory ( ) ;
303
+
304
+ TaskCompletionSource stop = new TaskCompletionSource ( ) ;
303
305
var mockApplicationLifetime = new Mock < IApplicationLifetime > ( ) ;
306
+ mockApplicationLifetime . Setup ( m => m . StopApplication ( ) ) . Callback ( ( ) => stop . TrySetResult ( ) ) ;
307
+
308
+ TaskCompletionSource restart = new TaskCompletionSource ( ) ;
304
309
var mockScriptHostManager = new Mock < IScriptHostManager > ( ) ;
310
+ mockScriptHostManager . Setup ( m => m . RestartHostAsync ( default ) ) . Callback ( ( ) => restart . TrySetResult ( ) ) ;
311
+
305
312
var mockEventManager = new ScriptEventManager ( ) ;
306
313
var environment = new TestEnvironment ( ) ;
307
314
@@ -311,18 +318,19 @@ public static async Task TestAppOfflineDebounceTime(string fileName, int delayIn
311
318
await fileMonitoringService . StartAsync ( new CancellationToken ( canceled : false ) ) ;
312
319
313
320
var offlineEventArgs = new FileSystemEventArgs ( WatcherChangeTypes . Created , tempDir , fileName ) ;
314
- FileEvent offlinefileEvent = new FileEvent ( "ScriptFiles" , offlineEventArgs ) ;
321
+ FileEvent offlineFileEvent = new FileEvent ( "ScriptFiles" , offlineEventArgs ) ;
315
322
316
323
var randomFileEventArgs = new FileSystemEventArgs ( WatcherChangeTypes . Created , tempDir , "random.txt" ) ;
317
324
FileEvent randomFileEvent = new FileEvent ( "ScriptFiles" , randomFileEventArgs ) ;
318
325
319
- mockEventManager . Publish ( offlinefileEvent ) ;
326
+ mockEventManager . Publish ( offlineFileEvent ) ;
320
327
await Task . Delay ( delayInMs ) ;
321
328
mockEventManager . Publish ( randomFileEvent ) ;
322
329
323
330
// Test
324
331
if ( expectShutdown )
325
332
{
333
+ await stop . Task . WaitAsync ( TimeSpan . FromSeconds ( 5 ) ) ;
326
334
mockApplicationLifetime . Verify ( m => m . StopApplication ( ) ) ;
327
335
}
328
336
else
@@ -332,6 +340,7 @@ public static async Task TestAppOfflineDebounceTime(string fileName, int delayIn
332
340
333
341
if ( expectRestart )
334
342
{
343
+ await restart . Task . WaitAsync ( TimeSpan . FromSeconds ( 5 ) ) ;
335
344
mockScriptHostManager . Verify ( m => m . RestartHostAsync ( default ) ) ;
336
345
}
337
346
else
0 commit comments