Exemple #1
0
 public TestFile([NotNull] TestVm test, Language language, FsProject <IAst> project, FileStatistics statistics)
     : base(test.TestPath, language, project, statistics)
 {
     if (test == null)
     {
         throw new ArgumentNullException("test");
     }
     _test = test;
 }
Exemple #2
0
 public void CalcDependProps(TestVm testVm)
 {
 }
Exemple #3
0
        private static void Diff(TestVm test)
        {
            var textA = Split(test.Gold);
              var textB = Split(test.PrettyPrintResult);
              const int rangeToShow = 3;
              var indexA = 0;
              var output = new List<string>();

              foreach (var diffItem in textA.Diff(textB))
              {
            //в начале итерации indexA содержит индекс строки идущей сразу за предыдущим блоком

            // определяем нужно ли выводить разделитель
            if (diffItem.Index - indexA > rangeToShow * 2)
            {
              //показываем строки идущие после предыдущего блока
              for (var i = 0; i < rangeToShow; ++i)
              {
            PrintLine("  " + textA[indexA]);
            ++indexA;
              }

              PrintLine("  " + "...", ConsoleColor.Gray);

              //показываем строки идущие перед текущим блоком
              indexA = diffItem.Index - rangeToShow;
              for (var i = 0; i < rangeToShow; ++i)
              {
            PrintLine("  " + textA[indexA]);
            ++indexA;
              }
            }
            else
            {
              //показываем строки между блоками
              while (indexA < diffItem.Index)
              {
            PrintLine("  " + textA[indexA]);
            ++indexA;
              }
            }

            // показываем удаленные строки
            for (var i = 0; i < diffItem.Deleted; ++i)
            {
              PrintLine("- " + textA[indexA], ConsoleColor.Red);
              ++indexA;
            }

            // показываем добавленные строки
            foreach (var insertedItem in diffItem.Inserted)
              PrintLine("+ " + insertedItem, ConsoleColor.Green);
              }

              // показываем не более rangeToShow последующих строк
              var tailLinesToShow = Math.Min(rangeToShow, textA.Length - indexA);

              for (var i = 0; i < tailLinesToShow; ++i)
              {
            PrintLine("  " + textA[indexA]);
            ++indexA;
              }

              if (indexA < textA.Length)
            PrintLine("  " + "...", ConsoleColor.Gray);

              PrintLine("END-DIFF", ConsoleColor.Gray);
        }
Exemple #4
0
        private void ShowDiff(TestVm test)
        {
            _para.Inlines.Clear();

              if (test.PrettyPrintResult == null)
              {
            _para.Inlines.AddRange(new Inline[] { new Run("The test was never started.") { Foreground = Brushes.Gray } });
            return;
              }

              if (test.TestState == TestState.Failure)
              {
            var lines = Diff(Split(test.Gold), Split(test.PrettyPrintResult));
            lines.RemoveAt(0);
            lines.RemoveAt(lines.Count - 1);

            foreach (var line in lines)
              _para.Inlines.AddRange(line);
              }
              else if (test.TestState == TestState.Success)
            _para.Inlines.AddRange(new Inline[] { new Run("Output of the test and the 'gold' are identical.") { Foreground = Brushes.LightGreen } });
        }
Exemple #5
0
        private void RunTest(TestVm test)
        {
            test.Run();

              ShowDiff(test);
        }
Exemple #6
0
    private static bool RunTestFile(TestVm testFile)
    {
      testFile.Run(RecoveryAlgorithm.Smart);

      switch (testFile.TestState)
      {
        case TestState.Skipped:
          ContinuePrint("skipped.", ConsoleColor.Yellow);
          break;
        case TestState.Failure:
          ContinuePrint("failed!", ConsoleColor.Red);
          Indent();
          Diff(testFile);
          Unindent();

          return true;

        case TestState.Ignored:
          ContinuePrint("ignored.", ConsoleColor.Yellow);
          break;
        case TestState.Inconclusive:
          ContinuePrint("inconclusive.", ConsoleColor.Yellow);
          break;
        case TestState.Success:
          ContinuePrint("passed.", ConsoleColor.Green);
          break;
      }

      return false;
    }
Exemple #7
0
    private void RunTest(TestVm test)
    {
      test.Run(recoveryAlgorithm: GetRecoveryAlgorithm());

      ShowDiff(test);
    }
Exemple #8
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;
 }
Exemple #9
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;
 }
Exemple #10
0
 public void CalcDependProps(TestVm testVm)
 {
   
 }