Skip to content

Commit 073a020

Browse files
committed
Failing test for watching a SubFileSystem involving case sensitivity
Watcher events get silently discarded if all conditions are met: * SubFileSystem was created with incorrect case * Changed file path includes a ~ * Any segment of changed file path is short enough to possibly be a SFN
1 parent a4b9faf commit 073a020

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/Zio.Tests/FileSystems/TestSubFileSystem.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,43 @@ public void TestWatcher()
7474
Assert.True(gotChange);
7575
}
7676

77+
[SkippableTheory]
78+
[InlineData("/test", "/test", "/foo.txt")]
79+
[InlineData("/test", "/test", "/~foo.txt")]
80+
[InlineData("/test", "/TEST", "/foo.txt")]
81+
[InlineData("/test", "/TEST", "/~foo.txt")]
82+
[InlineData("/verylongname", "/VERYLONGNAME", "/foo.txt")]
83+
[InlineData("/verylongname", "/VERYLONGNAME", "/~foo.txt")]
84+
public void TestWatcherCaseSensitive(string physicalDir, string subDir, string filePath)
85+
{
86+
Skip.IfNot(IsWindows, "This test involves case insensitivity on Windows");
87+
88+
var physicalFs = GetCommonPhysicalFileSystem();
89+
physicalFs.CreateDirectory(physicalDir);
90+
91+
Assert.True(physicalFs.DirectoryExists(physicalDir));
92+
Assert.True(physicalFs.DirectoryExists(subDir));
93+
94+
var subFs = new SubFileSystem(physicalFs, subDir);
95+
var watcher = subFs.Watch("/");
96+
97+
var gotChange = false;
98+
watcher.Created += (sender, args) =>
99+
{
100+
if (args.FullPath == filePath)
101+
{
102+
gotChange = true;
103+
}
104+
};
105+
106+
watcher.IncludeSubdirectories = true;
107+
watcher.EnableRaisingEvents = true;
108+
109+
physicalFs.WriteAllText($"{physicalDir}{filePath}", "test");
110+
Thread.Sleep(100);
111+
Assert.True(gotChange);
112+
}
113+
77114
[SkippableFact]
78115
public void TestDirectorySymlink()
79116
{

0 commit comments

Comments
 (0)