internal virtual void RefreshView()
            {
                if (RunResult != null)
                {
                    switch (RunResult.Type)
                    {
                    case TestResults.Success: ResultsTreeNode.ImageIndex = ResultsTreeNode.SelectedImageIndex = 1; break;

                    case TestResults.Failed: ResultsTreeNode.ImageIndex = ResultsTreeNode.SelectedImageIndex = 2; break;

                    case TestResults.Warning: ResultsTreeNode.ImageIndex = ResultsTreeNode.SelectedImageIndex = 3; break;

                    case TestResults.Executing: ResultsTreeNode.ImageIndex = ResultsTreeNode.SelectedImageIndex = 6; break;
                    }

                    if (ResultsTreeNode.Tag != RunResult)
                    {
                        ResultsTreeNode.Tag = RunResult;

                        MultipleTestResult multipleResult = RunResult as MultipleTestResult;
                        if (multipleResult != null && multipleResult.InnerResults != null)
                        {
                            for (int i = 0; i < multipleResult.InnerResults.Count; i++)
                            {
                                System.Windows.Forms.TreeNode runNode = new System.Windows.Forms.TreeNode(string.Format("Run #{0}", i + 1));
                                TestResult runResult = multipleResult.InnerResults[i];

                                switch (runResult.Type)
                                {
                                case TestResults.Success: runNode.ImageIndex = runNode.SelectedImageIndex = 1;
                                    break;

                                case TestResults.Failed: runNode.ImageIndex = runNode.SelectedImageIndex = 2;
                                    break;

                                case TestResults.Warning: runNode.ImageIndex = runNode.SelectedImageIndex = 3;
                                    break;

                                case TestResults.Executing: runNode.ImageIndex = runNode.SelectedImageIndex = 6;
                                    break;
                                }

                                runNode.Tag = runResult;
                                ResultsTreeNode.Nodes.Add(runNode);
                            }
                        }

                        if (!TreeNode.Nodes.Contains(ResultsTreeNode) && TreeNode.Tag != ResultsTreeNode.Tag)
                        {
                            TreeNode.Nodes.Insert(0, ResultsTreeNode);
                        }

                        if (RunResult.Type != TestResults.Success)
                        {
                            TreeNode.Expand();
                        }
                        else if (!(this is ITestContainer))
                        {
                            TreeNode.Collapse();
                        }
                    }
                }
            }
            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();
                }
            }