/// <summary> /// Get the results associated with a test case /// </summary> /// <param name="stub">The work item to get the results for</param> private void GetTestResults(WorkItemStub stub, string project) { //Return all of the test results in which this test case was executed string query = string.Format("SELECT * FROM TestResult WHERE TestCaseId = {0}", stub.ID); int planId = 0; //Get the list of results for the test case foreach (ITestCaseResult tcr in _tmp.TestResults.Query(query)) { #region Get the Test Plan string runQuery = string.Format("SELECT * FROM TestRun WHERE TestRunId = {0}", tcr.TestRunId); //There should only be one value returned so just get the first one foreach (ITestRun tr in _tms.QueryTestRuns(runQuery)) { planId = tr.TestPlanId; break; } //Is this part of a test plan that we already have? TestPlanInfo plan = _testPlans.Find( delegate(TestPlanInfo tpi) { return(tpi.TestPlanID == planId); } ); //If not, add it if (plan == null) { string planQuery = string.Format("SELECT * FROM TestPlan WHERE PlanId = {0}", planId); foreach (ITestPlan testPlan in _tmp.TestPlans.Query(planQuery)) { plan = new TestPlanInfo() { TestPlanID = planId, TestPlanName = testPlan.Name }; _testPlans.Add(plan); break; } } #endregion //Check to see if we've added the test run already bool found = false; for (int k = 0; k < plan.TestRuns.Count; k++) { if (plan.TestRuns[k].ID == tcr.TestRunId) { found = true; } } //If not, add it if (!found) { plan.TestRuns.Add(new TestRunStub() { ID = tcr.TestRunId, Url = GetURL(UrlType.TestRun, tcr.TestRunId, 0, project) }); } //add the results TestResultStub resultStub = new TestResultStub(); resultStub.TestPlan = plan; resultStub.TestCaseID = tcr.TestCaseId; resultStub.TestResultID = tcr.TestResultId; resultStub.TestRunID = tcr.TestRunId; resultStub.Outcome = tcr.Outcome; resultStub.Url = GetURL(UrlType.TestResult, tcr.TestRunId, tcr.TestResultId, project); stub.TestResults.Add(resultStub); } }
/// <summary> /// Get the results associated with a test case /// </summary> /// <param name="stub">The work item to get the results for</param> private void GetTestResults(WorkItemStub stub, string project) { //Return all of the test results in which this test case was executed string query = string.Format("SELECT * FROM TestResult WHERE TestCaseId = {0}", stub.ID); int planId = 0; //Get the list of results for the test case foreach (ITestCaseResult tcr in _tmp.TestResults.Query(query)) { #region Get the Test Plan string runQuery = string.Format("SELECT * FROM TestRun WHERE TestRunId = {0}", tcr.TestRunId); //There should only be one value returned so just get the first one foreach (ITestRun tr in _tms.QueryTestRuns(runQuery)) { planId = tr.TestPlanId; break; } //Is this part of a test plan that we already have? TestPlanInfo plan = _testPlans.Find( delegate(TestPlanInfo tpi) { return tpi.TestPlanID == planId; } ); //If not, add it if (plan == null) { string planQuery = string.Format("SELECT * FROM TestPlan WHERE PlanId = {0}", planId); foreach (ITestPlan testPlan in _tmp.TestPlans.Query(planQuery)) { plan = new TestPlanInfo() { TestPlanID = planId, TestPlanName = testPlan.Name }; _testPlans.Add(plan); break; } } #endregion //Check to see if we've added the test run already bool found = false; for (int k = 0; k < plan.TestRuns.Count; k++) { if (plan.TestRuns[k].ID == tcr.TestRunId) { found = true; } } //If not, add it if (!found) plan.TestRuns.Add(new TestRunStub() { ID = tcr.TestRunId, Url = GetURL(UrlType.TestRun, tcr.TestRunId, 0, project) }); //add the results TestResultStub resultStub = new TestResultStub(); resultStub.TestPlan = plan; resultStub.TestCaseID = tcr.TestCaseId; resultStub.TestResultID = tcr.TestResultId; resultStub.TestRunID = tcr.TestRunId; resultStub.Outcome = tcr.Outcome; resultStub.Url = GetURL(UrlType.TestResult, tcr.TestRunId, tcr.TestResultId, project); stub.TestResults.Add(resultStub); } }