Пример #1
0
 public virtual void ClearResults()
 {
     RunResult = null;
     ResultsTreeNode.Nodes.Clear();
     ResultsTreeNode.Remove();
     WaitHandle.Reset();
 }
Пример #2
0
            internal virtual void Run()
            {
                try
                {
                    if (RunResult != null)
                    {
                        throw new ApplicationException("Clear the results before running again");
                    }

                    if (CheckBoxes && !TreeNode.Checked)
                    {
                        return;
                    }

                    bool bMultipleRuns = false;
                    int  repeatCount   = int.MaxValue;

                    if (RepeatCount != null)
                    {
                        int tmp;
                        if (int.TryParse(RepeatCount, out tmp))
                        {
                            repeatCount   = tmp;
                            bMultipleRuns = true;
                        }
                    }

                    double repeatDuration = double.MaxValue;

                    if (RepeatDuration != null)
                    {
                        double tmp;
                        if (double.TryParse(RepeatDuration, out tmp))
                        {
                            repeatDuration = tmp;
                            bMultipleRuns  = true;
                        }
                    }

                    TestResult result = null;

                    if (bMultipleRuns)
                    {
                        int counter = 0;
                        int errors = 0, warnings = 0;
                        List <TestResult> innerResults = new List <TestResult>();
                        DateTime          startTime = DateTime.Now;
                        DateTime          maxTime = repeatDuration == double.MaxValue ? DateTime.MaxValue : startTime.AddSeconds(repeatDuration);

                        while (counter < repeatCount && DateTime.Now <= maxTime)
                        {
                            TestResult runResult;

                            runResult = RunOnce();
                            innerResults.Add(runResult);

                            switch (runResult.Type)
                            {
                            case TestResults.Failed: errors++;
                                break;

                            case TestResults.Warning: warnings++;
                                break;
                            }

                            counter++;
                        }

                        MultipleTestResult multipleResult;

                        if (errors > 0)
                        {
                            multipleResult = new MultipleTestResult(TestResults.Failed);
                        }
                        else if (warnings > 0)
                        {
                            multipleResult = new MultipleTestResult(TestResults.Warning);
                        }
                        else
                        {
                            multipleResult = new MultipleTestResult(TestResults.Success);
                        }

                        multipleResult.StartTime    = startTime;
                        multipleResult.InnerResults = innerResults;

                        ResultsTreeNode.Expand();

                        result = multipleResult;
                    }
                    else
                    {
                        result = RunOnce();
                    }

                    RunResult = result;
                    ReportFinished();
                }
                finally
                {
                    WaitHandle.Set();
                }
            }