/// <summary>
        /// Gets the most recent execution comment.
        /// </summary>
        /// <param name="testPlan">The test plan.</param>
        /// <param name="testCaseId">The test case unique identifier.</param>
        /// <returns></returns>
        public static string GetMostRecentExecutionComment(ITestPlan testPlan, int testCaseId)
        {
            var        testPoints    = TestPointManager.GetTestPointsByTestCaseId(testPlan, testCaseId);
            ITestPoint lastTestPoint = null;

            if (testPoints.Count > 0)
            {
                lastTestPoint = testPoints.Last();
            }
            string mostRecentExecutionComment = string.Empty;

            if (lastTestPoint != null && lastTestPoint.MostRecentResult != null && !string.IsNullOrEmpty(lastTestPoint.MostRecentResult.Comment))
            {
                mostRecentExecutionComment = lastTestPoint.MostRecentResult.Comment;
            }

            return(mostRecentExecutionComment);
        }
        /// <summary>
        /// Gets the most recent test case result.
        /// </summary>
        /// <param name="testPlan">The test plan.</param>
        /// <param name="testCaseId">The test case unique identifier.</param>
        /// <returns></returns>
        public static string GetMostRecentTestCaseResult(ITestPlan testPlan, int testCaseId)
        {
            var        testPoints    = TestPointManager.GetTestPointsByTestCaseId(testPlan, testCaseId);
            ITestPoint lastTestPoint = null;

            if (testPoints.Count > 0)
            {
                lastTestPoint = testPoints.Last();
            }
            string          mostRecentResult   = "Active";
            ITestCaseResult lastTestCaseResult = null;

            if (lastTestPoint != null)
            {
                lastTestCaseResult = lastTestPoint.MostRecentResult;
            }
            if (lastTestCaseResult != null)
            {
                mostRecentResult = lastTestCaseResult.Outcome.ToString();
            }

            return(mostRecentResult);
        }
        /// <summary>
        /// Gets the latest execution times.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="testPlan">The test plan.</param>
        /// <param name="testCaseId">The test case identifier.</param>
        /// <returns>
        /// latest execution times
        /// </returns>
        public static List <TestCaseRunResult> GetLatestExecutionTimes(ITestManagementTeamProject project, ITestPlan testPlan, int testCaseId)
        {
            List <TestCaseRunResult> executionTimes = new List <TestCaseRunResult>();
            var testPoints = TestPointManager.GetTestPointsByTestCaseId(testPlan, testCaseId);
            List <TestCaseResultIdentifier> alreadyAddedRuns = new List <TestCaseResultIdentifier>();

            if (testPoints != null && testPoints.Count > 0)
            {
                foreach (ITestPoint currentTestPoint in testPoints)
                {
                    if (currentTestPoint.History != null)
                    {
                        foreach (var currentHistoryTestPoint in currentTestPoint.History)
                        {
                            if (currentHistoryTestPoint != null &&
                                currentHistoryTestPoint.MostRecentResultId != 0 &&
                                currentHistoryTestPoint.MostRecentResultId != 0 &&
                                currentHistoryTestPoint.MostRecentResultOutcome.Equals(TestOutcome.Passed))
                            {
                                ITestCaseResult testRun = project.TestResults.Find(currentHistoryTestPoint.MostRecentRunId, currentHistoryTestPoint.MostRecentResultId);
                                if (testRun.Duration.Ticks > 0 && !alreadyAddedRuns.Contains(testRun.Id))
                                {
                                    executionTimes.Add(new TestCaseRunResult(
                                                           testRun.DateStarted,
                                                           testRun.DateCompleted,
                                                           testRun.Duration,
                                                           testRun.RunByName));
                                    alreadyAddedRuns.Add(testRun.Id);
                                }
                            }
                        }
                    }
                }
            }

            return(executionTimes);
        }