@@ -84,32 +84,40 @@ public void FileSystemWatcher_SymbolicLink_TargetsDirectory_Create_IncludeSubdir
8484 FileSystemWatcherTest . Execute ( ( ) =>
8585 {
8686 // Arrange
87+ // Layout on disk:
88+ // tempDir/ <- real directory
89+ // tempDir/subDir/ <- tempSubDir (real path)
90+ // linkPath -> tempDir <- symbolic link watched by FileSystemWatcher
91+ //
92+ // Paths used in assertions are expressed via the link so that they match
93+ // the paths the watcher reports (e.g. linkPath/subDir/subDirLv2).
8794 const string subDir = "subDir" ;
8895 const string subDirLv2 = "subDirLv2" ;
8996 string tempDir = GetTestFilePath ( ) ;
90- string tempSubDir = CreateTestDirectory ( tempDir , subDir ) ;
97+ string tempSubDir = CreateTestDirectory ( tempDir , subDir ) ; // tempDir/subDir/
9198
92- string linkPath = CreateSymbolicLinkToTarget ( tempDir , isDirectory : true ) ;
99+ string linkPath = CreateSymbolicLinkToTarget ( tempDir , isDirectory : true ) ; // linkPath -> tempDir
93100 using var watcher = new FileSystemWatcher ( linkPath ) ;
94101 watcher . NotifyFilter = NotifyFilters . DirectoryName ;
95102
96- string subDirLv2Path = Path . Combine ( tempSubDir , subDirLv2 ) ;
103+ string subDirLv2Path = Path . Combine ( tempSubDir , subDirLv2 ) ; // tempDir/subDir/subDirLv2 (real path for I/O)
97104
98105 // Act - Assert
99- // Only check for events at the specific nested path; spurious events at other paths (e.g. from
100- // directory setup) should not cause the test to fail.
106+ // Only check for events at the specific nested path (linkPath/subDir/subDirLv2);
107+ // spurious events at other paths (e.g. linkPath/subDir from directory setup) should
108+ // not cause the test to fail.
101109 ExpectNoEvent ( watcher , WatcherChangeTypes . Created ,
102110 action : ( ) => Directory . CreateDirectory ( subDirLv2Path ) ,
103111 cleanup : ( ) => Directory . Delete ( subDirLv2Path ) ,
104- expectedPath : Path . Combine ( linkPath , subDir , subDirLv2 ) ) ;
112+ expectedPath : Path . Combine ( linkPath , subDir , subDirLv2 ) ) ; // linkPath/subDir/subDirLv2
105113
106114 // Turn include subdirectories on.
107115 watcher . IncludeSubdirectories = true ;
108116
109117 ExpectEvent ( watcher , WatcherChangeTypes . Created ,
110118 action : ( ) => Directory . CreateDirectory ( subDirLv2Path ) ,
111119 cleanup : ( ) => Directory . Delete ( subDirLv2Path ) ,
112- expectedPath : Path . Combine ( linkPath , subDir , subDirLv2 ) ) ;
120+ expectedPath : Path . Combine ( linkPath , subDir , subDirLv2 ) ) ; // linkPath/subDir/subDirLv2
113121 } , maxAttempts : DefaultAttemptsForExpectedEvent , backoffFunc : ( iteration ) => RetryDelayMilliseconds , retryWhen : e => e is XunitException ) ;
114122 }
115123
0 commit comments