Inheritance: FullPathVm, ITest, ITestTreeContainerNode
Ejemplo n.º 1
0
        public TestVm(string testPath, int id, ITestTreeNode parent)
            : base(parent, testPath)
        {
            _testFolder = parent as TestFolderVm;
            TestPath    = testPath;
            TestSuite   = _testFolder == null ? (TestSuiteVm)parent : _testFolder.TestSuite;

            if (_testFolder != null)
            {
                Statistics     = null;
                FileStatistics = new FileStatistics(
                    _testFolder.ParsingStatistics.ReplaceSingleSubtask(Name),
                    _testFolder.ParseTreeStatistics.ReplaceSingleSubtask(Name),
                    _testFolder.AstStatistics.ReplaceSingleSubtask(Name),
                    _testFolder.DependPropsStatistics);
                _file = new TestFile(this, TestSuite.Language, id, _testFolder.Project, FileStatistics);
            }
            else
            {
                Statistics     = new StatisticsTask.Container("Total");
                FileStatistics = new FileStatistics(
                    Statistics.ReplaceSingleSubtask("Parsing"),
                    Statistics.ReplaceSingleSubtask("ParseTree"),
                    Statistics.ReplaceSingleSubtask("Ast", "AST Creation"),
                    Statistics.ReplaceContainerSubtask("DependProps", "Dependent properties"));
                var solution = new FsSolution <IAst>();
                var project  = new FsProject <IAst>(solution, Path.GetDirectoryName(testPath), TestSuite.Libs);
                _file = new TestFile(this, TestSuite.Language, id, project, FileStatistics);
            }

            if (TestSuite.TestState == TestState.Ignored)
            {
                TestState = TestState.Ignored;
            }
        }
Ejemplo n.º 2
0
 private void RunTest(TestFolderVm testFolder)
 {
   foreach (var testFile in testFolder.Tests)
     RunTest(testFile);
 }
Ejemplo n.º 3
0
 private static TestVm AddNewFileToMultitest(TestFolderVm testFolder)
 {
   var name = MakeTestFileName(testFolder);
   var path = Path.Combine(testFolder.TestPath, name + ".test");
   File.WriteAllText(path, Environment.NewLine, Encoding.UTF8);
   var newTest = new TestVm(path, testFolder.Tests.Count, testFolder);
   testFolder.Tests.Add(newTest);
   return newTest;
 }
Ejemplo n.º 4
0
    private void AddFile_MenuItem_OnClick(object sender, RoutedEventArgs e)
    {
      TestFolderVm testFolder;
      var test = _testsTreeView.SelectedItem as TestVm;
      if (test != null)
      {
        var dirPath = Path.ChangeExtension(test.TestPath, null);
        if (!Directory.Exists(dirPath))
          Directory.CreateDirectory(dirPath);

        testFolder = new TestFolderVm(dirPath, test.TestSuite);
        var suite = (TestSuiteVm)test.Parent;
        var index = suite.Tests.IndexOf(test);
        suite.Tests[index] = testFolder;

        var firstFilePath = Path.Combine(dirPath, MakeTestFileName(testFolder) + ".test");
        if (File.Exists(test.TestPath))
          File.Move(test.TestPath, firstFilePath);
        else
          File.WriteAllText(firstFilePath, Environment.NewLine, Encoding.UTF8);

        if (File.Exists(test.GolgPath))
          File.Move(test.GolgPath, Path.ChangeExtension(firstFilePath, ".gold"));

        testFolder.Tests.Add(new TestVm(firstFilePath, testFolder.Tests.Count, testFolder));

        AddNewFileToMultitest(testFolder).IsSelected = true;
        return;
      }

      testFolder = _testsTreeView.SelectedItem as TestFolderVm;
      if (testFolder != null)
      {
        AddNewFileToMultitest(testFolder).IsSelected = true;
      }
    }
Ejemplo n.º 5
0
    private static string MakeTestFileName(TestFolderVm testFolder)
    {
      var names = new bool['Z' - 'A'];
      foreach (var t in testFolder.Tests)
      {
        var name = t.Name;
        if (name.Length == 1)
        {
          var ch = name[0];
          if (ch >= 'A' && ch <= 'Z')
            names[ch - 'A'] = true;
        }
      }

      for (int i = 0; i < names.Length; i++)
        if (!names[i])
          return ((char)('A' + i)).ToString();

      return Path.GetFileNameWithoutExtension(Path.GetTempFileName());
    }
Ejemplo n.º 6
0
 private void ChangeCurrentTest(TestSuiteVm newTestSuite, TestFolderVm newTestFolder, TestVm newTest, string code)
 {
   if (newTestSuite != _currentTestSuite && newTestSuite != null)
   {
     _highlightingStyles.Clear();
     foreach (var spanClass in newTestSuite.Language.GetSpanClasses())
       _highlightingStyles.Add(spanClass.FullName, MakeHighlightingColor(spanClass));
   }
   _currentTestSuite = newTestSuite;
   _currentTestFolder = newTestFolder;
   _currentTest = newTest;
   _text.Text = code;
 }