public void SearchFileWith34txt() { countOfFilteredFiles = 0; FileSystemVisitor.FileSystemVisitor _systemVisitor = new FileSystemVisitor.FileSystemVisitor(@"D:\Info", FindAFile); _systemVisitor.OnFilteredDirectoryFinded += SystemVisitor_OnFilteredDirectoryFinded; _systemVisitor.OnFilteredFileFinded += SystemVisitor_OnFilteredFileFinded; IEnumerable str = _systemVisitor.Searching(); Assert.AreEqual(1, countOfFilteredFiles); }
public void SearchWithoutFilters() { var countOfFile = 0; FileSystemVisitor.FileSystemVisitor _systemVisitor = new FileSystemVisitor.FileSystemVisitor(@"D:\Info"); IEnumerable str = _systemVisitor.Searching(); foreach (var item in str) { countOfFile++; } Assert.AreEqual(5, countOfFile); }
static void Main(string[] args) { int counter = 0; var visitor = new Visitor(ConfigurationManager.AppSettings["test_FolderPath"]); visitor.Start += () => Console.WriteLine("Started"); visitor.Finish += () => Console.WriteLine("Finished"); visitor.FileFound += (s, e) => Console.WriteLine("File Finded"); visitor.DirectoryFound += (s, e) => Console.WriteLine("Dir Finded"); visitor.FilteredDirectoryFound += (s, e) => { Console.WriteLine("Filtered dir finded"); e.RemoveItem = true; }; visitor.FilteredFileFound += (s, e) => Console.WriteLine("Filtered file finded"); visitor.FilteredFileFound += (s, e) => { counter++; if (counter > 4) { e.RemoveItem = true; } if (counter > 8) { e.StopSearch = true; } }; try { foreach (var item in visitor) { Console.WriteLine(item); Console.WriteLine("-------------------------"); } } catch (UnauthorizedAccessException) { } Console.Read(); }
public void CheckOfEventsCountWithoutFilters() { countOfEvents = 0; FileSystemVisitor _systemVisitor = new FileSystemVisitor.FileSystemVisitor(@"D:\Info"); _systemVisitor.OnStart += _systemVisitor_OnStart; _systemVisitor.OnFinish += _systemVisitor_OnFinish; _systemVisitor.OnFileFinded += SystemVisitor_OnFileFinded; _systemVisitor.OnDirectoryFinded += SystemVisitor_OnDirectoryFinded; _systemVisitor.OnFilteredDirectoryFinded += SystemVisitor_OnFilteredDirectoryFinded; _systemVisitor.OnFilteredFileFinded += SystemVisitor_OnFilteredFileFinded; IEnumerable str = _systemVisitor.Searching(); Assert.AreEqual(7, countOfEvents); }
public void TestInit() { _fileSystemVisitor = new FileSystemVisitor.FileSystemVisitor(); _directoryTraverserTest = new DirectoryTraverserTest(testFolderPath); string[] testDirs = { MakePath(testFolderPath, "Test"), MakePath(testFolderPath, "Test", "dir1") }; string[] testFiles = { MakePath(testFolderPath, "Test", "dir1", "file1.txt"), MakePath(testFolderPath, "Test", "dir1", "file2.txt") }; _directoryTraverserTest.Setup(testDirs, testFiles); }
static void Main(string[] args) { string startPosition; Console.WriteLine("Введите начальный каталог:"); startPosition = Console.ReadLine(); if (!Directory.Exists(startPosition)) { Console.WriteLine("Задан неверный каталог!"); } else { FileSystemVisitor.FileSystemVisitor systemVisitor = new FileSystemVisitor.FileSystemVisitor(startPosition, CheckFiles); systemVisitor.OnStart += SystemVisitor_OnStart; systemVisitor.OnFinish += SystemVisitor_OnFinish; systemVisitor.OnFileFinded += SystemVisitor_OnFileFinded; systemVisitor.OnDirectoryFinded += SystemVisitor_OnDirectoryFinded; systemVisitor.OnFilteredDirectoryFinded += SystemVisitor_OnFilteredDirectoryFinded; systemVisitor.OnFilteredFileFinded += SystemVisitor_OnFilteredFileFinded; systemVisitor.Searching(); } Console.ReadLine(); }