Beispiel #1
0
 private bool processDir(TestDirNode testDirNode, DirectoryInfo directoryInfo, string outDir)
 {
     bool result = false;
     //
     if (!Directory.Exists(outDir))
     {
         Directory.CreateDirectory(outDir);
     }
     DirectoryInfo outDirInfo = new DirectoryInfo(outDir);
     //
     // Directories:
     //
     ObsoleteDirs obsoleteDirs = new ObsoleteDirs(outDirInfo);
     foreach (DirectoryInfo subDirectoryInfo in directoryInfo.EnumerateDirectories())
     {
         TestDirNode subTestDirNode = new TestDirNode(subDirectoryInfo.Name);
         if (processDir(subTestDirNode, subDirectoryInfo, Path.Combine(outDir, subDirectoryInfo.Name)))
         {
             obsoleteDirs.RemoveDirFromObsoleteList(subDirectoryInfo);
             testDirNode.AddSubDir(subTestDirNode);
             result = true;
         }
     }
     obsoleteDirs.DeleteDirs();
     //
     // Files:
     //
     ObsoleteFiles obsoleteFiles = new ObsoleteFiles(outDirInfo);
     foreach (FileInfo fileInfo in directoryInfo.EnumerateFiles("*.spec.js"))
     {
         string outFileName = fileInfo.Name + ".html";
         obsoleteFiles.RemoveFileFromObsoleteList(outFileName);
         string fullOutFileName = Path.Combine(outDir, outFileName);
         obsoleteFiles.RemoveFileFromObsoleteList(outFileName);
         //
         //Console.WriteLine(fileInfo.FullName);
         //Console.WriteLine("  " + fullOutFileName);
         //
         TestResultsInfo testResultInfo = RunMocha.Run(fileInfo.FullName, fullOutFileName);
         //TestResultsInfo testResultInfo = new TestResultsInfo();
         //
         //Console.WriteLine(string.Format("total={0} passed={1}", testResultInfo.Total, testResultInfo.Passed));
         TestItemNode itemNode = new TestItemNode() { Name = fileInfo.Name, ResultsInfo = testResultInfo };
         testDirNode.AddItem(itemNode);
         //
         //
         result = true;
     }
     obsoleteFiles.DeleteFiles();
     //
     if (!result)
     {
         Directory.Delete(outDir);
     }
     //
     return result;
 }
Beispiel #2
0
        private void addDirNavHtml(TestDirNode dirNode, StringBuilder sb, string indent=TAB)
        {
            foreach (TestDirNode subDir in dirNode.SubNodes)
            {
                sb.AppendLine(indent + "<li>");
                sb.AppendLine(indent + TAB + string.Format("<span class='nav-dir'>{0}{1}</span>", subDir.Name, subDir.ResultsInfo.CalcHtml()));
                sb.AppendLine(indent + TAB + "<ul>");
                this.addDirNavHtml(subDir, sb, indent + TAB + TAB);
                sb.AppendLine(indent + TAB + "</ul>");
                sb.AppendLine(indent + "</li>");
            }
            //
            foreach (TestItemNode item in dirNode.ItemNodes)
            {
                sb.AppendLine(indent + "<li>");
                sb.AppendLine(indent + TAB + string.Format("<a href='{0}'>{1}</a>{2}", item.CalcSiteUrl(), item.Name, item.ResultsInfo.CalcHtml()));
                sb.AppendLine(indent + "</li>");
            }

        }
Beispiel #3
0
 public void AddSubDir(TestDirNode subDir)
 {
     subDir.Parent = this;
     this.SubNodes.Add(subDir);
 }