Пример #1
0
        public void Test_It_FileFindedCall()
        {
            #region ARRANGE

            int delegatesCallCount = 0;

            #endregion

            #region ACT

            _fileFind.OnFileFinded(_fileInfo, null, (s, e) => delegatesCallCount++, null, OnEvent);

            #endregion

            #region ASSERT

            Assert.AreEqual(1, delegatesCallCount);

            #endregion
        }
        private IEnumerable <string> WalkDirectoryTree(DirectoryInfo root, ActionType currentAction)
        {
            DirectoryInfo[] subDirs = null;
            FileInfo[]      files   = root.GetFiles("*.*");

            if (files != null)
            {
                foreach (FileInfo fileInfo in files)
                {
                    currentAction = _fileFind.OnFileFinded(fileInfo.FullName, _filter, FileFinded, FilteredFileFinded, OnEvent);

                    if (currentAction == ActionType.Continue)
                    {
                        yield return(fileInfo.FullName);
                    }

                    if (currentAction == ActionType.Stop)
                    {
                        yield break;
                    }
                }

                subDirs = root.GetDirectories();

                foreach (DirectoryInfo dirInfo in subDirs)
                {
                    DirectoryFindedEventArgs args = new DirectoryFindedEventArgs {
                        DirInfo = dirInfo.FullName
                    };
                    DirectoryFinded(this, args);
                    currentAction = GetActionType(currentAction, args.ActionType);

                    if (currentAction != ActionType.Stop)
                    {
                        foreach (string fileInfo in WalkDirectoryTree(dirInfo, currentAction))
                        {
                            yield return(fileInfo);
                        }
                    }
                    else
                    {
                        yield break;
                    }
                }
            }
        }