Exemplo n.º 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;
 }
Exemplo n.º 2
0
 public void AddItem(TestItemNode item)
 {
     item.Parent = this;
     this.ItemNodes.Add(item);
 }