@@ -75,10 +75,15 @@ private InventoryBuilder CreateBuilder(IFileSystemInspector inspector)
7575 }
7676
7777 [ Test ]
78- public async Task Hidden_File_Is_Ignored ( )
78+ public async Task Hidden_Root_File_Is_Analyzed ( )
7979 {
8080 var insp = new Mock < IFileSystemInspector > ( MockBehavior . Strict ) ;
8181 insp . Setup ( i => i . IsHidden ( It . IsAny < FileSystemInfo > ( ) , It . IsAny < OSPlatforms > ( ) ) ) . Returns ( true ) ;
82+ insp . Setup ( i => i . IsSystem ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
83+ insp . Setup ( i => i . IsReparsePoint ( It . IsAny < FileSystemInfo > ( ) ) ) . Returns ( false ) ;
84+ insp . Setup ( i => i . Exists ( It . IsAny < FileInfo > ( ) ) ) . Returns ( true ) ;
85+ insp . Setup ( i => i . IsOffline ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
86+ insp . Setup ( i => i . IsRecallOnDataAccess ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
8287 var builder = CreateBuilder ( insp . Object ) ;
8388
8489 var filePath = Path . Combine ( TestDirectory . FullName , "a.txt" ) ;
@@ -89,15 +94,19 @@ public async Task Hidden_File_Is_Ignored()
8994 await builder . BuildBaseInventoryAsync ( invPath ) ;
9095
9196 var part = builder . Inventory . InventoryParts . Single ( ) ;
92- part . FileDescriptions . Should ( ) . BeEmpty ( ) ;
97+ part . FileDescriptions . Should ( ) . ContainSingle ( ) ;
9398 }
9499
95100 [ Test ]
96- public async Task System_File_Is_Ignored ( )
101+ public async Task System_Root_File_Is_Analyzed ( )
97102 {
98103 var insp = new Mock < IFileSystemInspector > ( MockBehavior . Strict ) ;
99104 insp . Setup ( i => i . IsHidden ( It . IsAny < FileSystemInfo > ( ) , It . IsAny < OSPlatforms > ( ) ) ) . Returns ( false ) ;
100105 insp . Setup ( i => i . IsSystem ( It . IsAny < FileInfo > ( ) ) ) . Returns ( true ) ;
106+ insp . Setup ( i => i . IsReparsePoint ( It . IsAny < FileSystemInfo > ( ) ) ) . Returns ( false ) ;
107+ insp . Setup ( i => i . Exists ( It . IsAny < FileInfo > ( ) ) ) . Returns ( true ) ;
108+ insp . Setup ( i => i . IsOffline ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
109+ insp . Setup ( i => i . IsRecallOnDataAccess ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
101110 var builder = CreateBuilder ( insp . Object ) ;
102111
103112 var filePath = Path . Combine ( TestDirectory . FullName , "b.txt" ) ;
@@ -108,7 +117,91 @@ public async Task System_File_Is_Ignored()
108117 await builder . BuildBaseInventoryAsync ( invPath ) ;
109118
110119 var part = builder . Inventory . InventoryParts . Single ( ) ;
111- part . FileDescriptions . Should ( ) . BeEmpty ( ) ;
120+ part . FileDescriptions . Should ( ) . ContainSingle ( ) ;
121+ }
122+
123+ [ Test ]
124+ public async Task Hidden_Root_Directory_Is_Analyzed ( )
125+ {
126+ var insp = new Mock < IFileSystemInspector > ( MockBehavior . Strict ) ;
127+ insp . Setup ( i => i . IsHidden ( It . IsAny < DirectoryInfo > ( ) , It . IsAny < OSPlatforms > ( ) ) ) . Returns ( true ) ;
128+ insp . Setup ( i => i . IsHidden ( It . IsAny < FileInfo > ( ) , It . IsAny < OSPlatforms > ( ) ) ) . Returns ( false ) ;
129+ insp . Setup ( i => i . IsSystem ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
130+ insp . Setup ( i => i . IsReparsePoint ( It . IsAny < FileSystemInfo > ( ) ) ) . Returns ( false ) ;
131+ insp . Setup ( i => i . Exists ( It . IsAny < FileInfo > ( ) ) ) . Returns ( true ) ;
132+ insp . Setup ( i => i . IsOffline ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
133+ insp . Setup ( i => i . IsRecallOnDataAccess ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
134+ var builder = CreateBuilder ( insp . Object ) ;
135+
136+ var root = Directory . CreateDirectory ( Path . Combine ( TestDirectory . FullName , "root_hidden" ) ) ;
137+ var filePath = Path . Combine ( root . FullName , "f.txt" ) ;
138+ await File . WriteAllTextAsync ( filePath , "x" ) ;
139+
140+ builder . AddInventoryPart ( root . FullName ) ;
141+ var invPath = Path . Combine ( TestDirectory . FullName , "inv_hidden_root.zip" ) ;
142+ await builder . BuildBaseInventoryAsync ( invPath ) ;
143+
144+ var part = builder . Inventory . InventoryParts . Single ( ) ;
145+ part . FileDescriptions . Should ( ) . ContainSingle ( ) ;
146+ part . FileDescriptions [ 0 ] . RelativePath . Should ( ) . Be ( "/f.txt" ) ;
147+ }
148+
149+ [ Test ]
150+ public async Task Hidden_Child_File_Is_Ignored ( )
151+ {
152+ var insp = new Mock < IFileSystemInspector > ( MockBehavior . Strict ) ;
153+ insp . Setup ( i => i . IsHidden ( It . IsAny < DirectoryInfo > ( ) , It . IsAny < OSPlatforms > ( ) ) ) . Returns ( false ) ;
154+ insp . Setup ( i => i . IsHidden ( It . Is < FileInfo > ( fi => fi . Name == "hidden.txt" ) , It . IsAny < OSPlatforms > ( ) ) )
155+ . Returns ( true ) ;
156+ insp . Setup ( i => i . IsHidden ( It . Is < FileInfo > ( fi => fi . Name != "hidden.txt" ) , It . IsAny < OSPlatforms > ( ) ) )
157+ . Returns ( false ) ;
158+ insp . Setup ( i => i . IsSystem ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
159+ insp . Setup ( i => i . IsReparsePoint ( It . IsAny < FileSystemInfo > ( ) ) ) . Returns ( false ) ;
160+ insp . Setup ( i => i . Exists ( It . IsAny < FileInfo > ( ) ) ) . Returns ( true ) ;
161+ insp . Setup ( i => i . IsOffline ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
162+ insp . Setup ( i => i . IsRecallOnDataAccess ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
163+ var builder = CreateBuilder ( insp . Object ) ;
164+
165+ var root = Directory . CreateDirectory ( Path . Combine ( TestDirectory . FullName , "root_hidden_child" ) ) ;
166+ var visiblePath = Path . Combine ( root . FullName , "visible.txt" ) ;
167+ var hiddenPath = Path . Combine ( root . FullName , "hidden.txt" ) ;
168+ await File . WriteAllTextAsync ( visiblePath , "x" ) ;
169+ await File . WriteAllTextAsync ( hiddenPath , "x" ) ;
170+
171+ builder . AddInventoryPart ( root . FullName ) ;
172+ var invPath = Path . Combine ( TestDirectory . FullName , "inv_hidden_child.zip" ) ;
173+ await builder . BuildBaseInventoryAsync ( invPath ) ;
174+
175+ var part = builder . Inventory . InventoryParts . Single ( ) ;
176+ part . FileDescriptions . Should ( ) . ContainSingle ( fd => fd . Name == "visible.txt" ) ;
177+ }
178+
179+ [ Test ]
180+ public async Task System_Child_File_Is_Ignored ( )
181+ {
182+ var insp = new Mock < IFileSystemInspector > ( MockBehavior . Strict ) ;
183+ insp . Setup ( i => i . IsHidden ( It . IsAny < DirectoryInfo > ( ) , It . IsAny < OSPlatforms > ( ) ) ) . Returns ( false ) ;
184+ insp . Setup ( i => i . IsHidden ( It . IsAny < FileInfo > ( ) , It . IsAny < OSPlatforms > ( ) ) ) . Returns ( false ) ;
185+ insp . Setup ( i => i . IsSystem ( It . Is < FileInfo > ( fi => fi . Name == "system.txt" ) ) ) . Returns ( true ) ;
186+ insp . Setup ( i => i . IsSystem ( It . Is < FileInfo > ( fi => fi . Name != "system.txt" ) ) ) . Returns ( false ) ;
187+ insp . Setup ( i => i . IsReparsePoint ( It . IsAny < FileSystemInfo > ( ) ) ) . Returns ( false ) ;
188+ insp . Setup ( i => i . Exists ( It . IsAny < FileInfo > ( ) ) ) . Returns ( true ) ;
189+ insp . Setup ( i => i . IsOffline ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
190+ insp . Setup ( i => i . IsRecallOnDataAccess ( It . IsAny < FileInfo > ( ) ) ) . Returns ( false ) ;
191+ var builder = CreateBuilder ( insp . Object ) ;
192+
193+ var root = Directory . CreateDirectory ( Path . Combine ( TestDirectory . FullName , "root_system_child" ) ) ;
194+ var visiblePath = Path . Combine ( root . FullName , "visible.txt" ) ;
195+ var systemPath = Path . Combine ( root . FullName , "system.txt" ) ;
196+ await File . WriteAllTextAsync ( visiblePath , "x" ) ;
197+ await File . WriteAllTextAsync ( systemPath , "x" ) ;
198+
199+ builder . AddInventoryPart ( root . FullName ) ;
200+ var invPath = Path . Combine ( TestDirectory . FullName , "inv_system_child.zip" ) ;
201+ await builder . BuildBaseInventoryAsync ( invPath ) ;
202+
203+ var part = builder . Inventory . InventoryParts . Single ( ) ;
204+ part . FileDescriptions . Should ( ) . ContainSingle ( fd => fd . Name == "visible.txt" ) ;
112205 }
113206
114207 [ Test ]
@@ -320,4 +413,4 @@ public async Task Directory_ReparsePoint_Is_Skipped()
320413 part . FileDescriptions . Should ( ) . ContainSingle ( ) ;
321414 part . FileDescriptions [ 0 ] . RelativePath . Should ( ) . Be ( "/ok.txt" ) ;
322415 }
323- }
416+ }
0 commit comments