private void EnqueueChildDirectory(DirectoryToIndex directoryToIndex, string fullDirectory, string subDirectory)
 {
     _directories.Enqueue(
         new DirectoryToIndex(
             fullDirectory: fullDirectory,
             parentDirectory: directoryToIndex.FullDirectory,
             description: subDirectory,
             nestDepth: directoryToIndex.NestDepth + 1)
         );
 }
        private void AddLinkToChildDirectoryAndEnqueue(DirectoryToIndex directoryToIndex, string fullDirectory)
        {
            if (fullDirectory.TrimEnd(_fileSystem.Path.DirectorySeparatorChar).ToLowerInvariant() != directoryToIndex.FullDirectory.TrimEnd(_fileSystem.Path.DirectorySeparatorChar).ToLowerInvariant())
            {
                var subDirectory = GetLastDirectoryName(fullDirectory);
                _formatter.AddLink(Index(subDirectory), subDirectory, "childLink");

                EnqueueChildDirectory(directoryToIndex, fullDirectory, subDirectory);
            }
        }
        void AddLinksToChildDirectories(DirectoryToIndex directoryToIndex)
        {
            var subDirectories = _fileSystem.Directory.GetDirectories(directoryToIndex.FullDirectory);

            if (subDirectories.Any())
            {
                using (new TidyUp(StartChildren, EndChildren))
                    _fileSystem.Directory.GetDirectories(directoryToIndex.FullDirectory).ToList().ForEach(fullDirectory => AddLinkToChildDirectoryAndEnqueue(directoryToIndex, fullDirectory));
            }
        }
        void AddLinkToParentDirectory(DirectoryToIndex directoryToIndex)
        {
            if (string.IsNullOrEmpty(directoryToIndex.ParentDirectory) == true)
            {
                return;
            }

            using (new TidyUp(StartParent, EndParent))
                _formatter.AddLink(Index(".."), GetLastDirectoryName(directoryToIndex.ParentDirectory), "parentLink");
        }
        private void AddIndex(DirectoryToIndex directoryToIndex)
        {
            using (new TidyUp(() => _formatter.StartIndex(directoryToIndex.Description, directoryToIndex.NestDepth), EndIndex))
            {
                AddLinkToParentDirectory(directoryToIndex);

                AddLinksToTestsAtDirectory(directoryToIndex);

                AddLinksToChildDirectories(directoryToIndex);
            }

            SaveIndex(Index(directoryToIndex.FullDirectory));
        }
 void AddLinksToTestsAtDirectory(DirectoryToIndex directoryToIndex)
 {
     using (new TidyUp(StartTests, EndTests))
         _fileSystem.Directory.GetFiles(directoryToIndex.FullDirectory, "*.html").ToList().ForEach(filename => AddLinkAtCurrentDirectory(filename));
 }