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]