/// <summary> /// Add step /// </summary> /// <param name="id"></param> /// <param name="text"></param> public void AddStep(int id, string text) { WorkItem workItem = ItemsStore.GetWorkItem(id); var popup = new StepActionsResult(); popup.action.Text = text; popup.Create(null, Icons.AddDetails); ITestManagementService testService = collection.GetService<ITestManagementService>(); var project = testService.GetTeamProject(workItem.Project.Name); var testCase = project.TestCases.Find(workItem.Id); var step = testCase.CreateTestStep(); if (!popup.IsCanceled) { switch (tfsVersion) { case TfsVersion.Tfs2011: step.Title = "<div><p><span>" + popup.action.Text + "</span></p></div>"; step.ExpectedResult = "<div><p><span>" + popup.expectedResult.Text + "</span></p></div>"; break; case TfsVersion.Tfs2010: step.Title = popup.action.Text; step.ExpectedResult = popup.expectedResult.Text; break; } //testCase.Actions.Clear(); testCase.Actions.Add(step); testCase.Save(); workItem.Save(); } }
/// <summary> /// The add step for work item "Test Case". /// </summary> /// <param name="dataObject"></param> /// <param name="workItem"></param> public void AddStep(IDataObject dataObject, WorkItem workItem, out bool comment,bool isAddStep) { var popup = new StepActionsResult(); string temp = Regex.Replace(dataObject.GetData(DataFormats.Text).ToString(), @"\s+", " "); popup.action.Text = temp; popup.Create(null, Icons.AddDetails); ITestManagementService testService = collection.GetService<ITestManagementService>(); var project = testService.GetTeamProject(workItem.Project.Name); var testCase = project.TestCases.Find(workItem.Id); var step = testCase.CreateTestStep(); if (!popup.IsCanceled) { switch (tfsVersion) { case TfsVersion.Tfs2011: step.Title = "<div><p><span>" + popup.action.Text + "</span></p></div>"; step.ExpectedResult = "<div><p><span>" + popup.expectedResult.Text + "</span></p></div>"; //step.Title = popup.action.Text; //step.ExpectedResult = popup.expectedResult.Text; break; case TfsVersion.Tfs2010: step.Title = popup.action.Text; step.ExpectedResult = popup.expectedResult.Text; break; } if (isAddStep) { testCase.Actions.Add(step); } else { testCase.Actions.Clear(); testCase.Actions.Add(step); } testCase.Save(); workItem.Save(); comment = true; } else { comment = false; } }