Exemple #1
0
        private static IEnumerable <string> SearchFiles(Config config)
        {
            var enumerator = new FileEnumerator(new NativeFileSystem());
            var filter     = new SearchFilter()
                             .IncludeDirectories(config.Search.IncludedDirectories)
                             .IncludeExtensions(config.Search.IncludedExtensions)
                             .ExcludeDirectories(config.Search.ExcludedDirectories)
                             .ExcludeExtensions(config.Search.ExcludedExtensions);

            return(enumerator.FindFiles(config.Search.RootDirectory, filter));
        }
Exemple #2
0
        public void 在檔案系統中搜尋exe應回傳檔案完整路徑()
        {
            // Arrange
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"C:\Windows\bfsvc.exe", new MockFileData("") },
                { @"C:\Windows\win.ini", new MockFileData("") },
                { @"C:\Windows\winhlp32.exe", new MockFileData("") }
            });
            var enumerator = new FileEnumerator(fileSystem);
            var filter     = new SearchFilter().IncludeExtension(".exe");

            // Act
            var result = enumerator.FindFiles(@"C:\Windows", filter);

            // Assert
            Assert.IsTrue(result.Contains(@"C:\Windows\bfsvc.exe"));
        }