From a68e9e9c4768b267492c67b7c1f7f570dbda73c1 Mon Sep 17 00:00:00 2001 From: James King Date: Fri, 21 Jun 2024 12:03:39 +0100 Subject: [PATCH] Use a ManualResetEvent in TestSubFileSystem.TestWatcherCaseSensitive A bit friendlier for CI runners --- src/Zio.Tests/FileSystems/TestSubFileSystem.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Zio.Tests/FileSystems/TestSubFileSystem.cs b/src/Zio.Tests/FileSystems/TestSubFileSystem.cs index d43decf..9768f00 100644 --- a/src/Zio.Tests/FileSystems/TestSubFileSystem.cs +++ b/src/Zio.Tests/FileSystems/TestSubFileSystem.cs @@ -93,13 +93,13 @@ public void TestWatcherCaseSensitive(string physicalDir, string subDir, string f var subFs = new SubFileSystem(physicalFs, subDir); var watcher = subFs.Watch("/"); + var waitHandle = new ManualResetEvent(false); - var gotChange = false; watcher.Created += (sender, args) => { if (args.FullPath == filePath) { - gotChange = true; + waitHandle.Set(); } }; @@ -107,8 +107,8 @@ public void TestWatcherCaseSensitive(string physicalDir, string subDir, string f watcher.EnableRaisingEvents = true; physicalFs.WriteAllText($"{physicalDir}{filePath}", "test"); - Thread.Sleep(100); - Assert.True(gotChange); + + Assert.True(waitHandle.WaitOne(100)); } [SkippableFact]