예제 #1
0
 private static void LoadTestSteps(ITestCase testCase, Microsoft.TeamFoundation.TestManagement.Client.ITestCase newTestCase)
 {
     foreach (ITestCaseStep step in testCase.Steps)
     {
         ITestStep testStep = newTestCase.CreateTestStep();
         testStep.Title          = step.Actions;
         testStep.Description    = step.Actions;
         testStep.ExpectedResult = step.ExpectedResults;
         testStep.TestStepType   = string.IsNullOrEmpty(testStep.ExpectedResult) ? TestStepType.ActionStep : TestStepType.ValidateStep;
         newTestCase.Actions.Add(testStep);
     }
 }
예제 #2
0
        private List <TestCaseConflict> CreateTestCases(ITestManagementTeamProject selectedProject, TestSuite testSuite, IStaticTestSuite newSuite, bool throwExceptionIfTestCaseConflicts)
        {
            List <TestCaseConflict> result = new List <TestCaseConflict>();

            ITestSuiteEntryCollection suitcollection = newSuite.Entries;

            foreach (ITestCase testCase in testSuite.TestCases)
            {
                ITestSuiteEntry obj = (from o in suitcollection where string.Compare(o.Title, testCase.Name, true) == 0 select o).FirstOrDefault() as ITestSuiteEntry;
                Microsoft.TeamFoundation.TestManagement.Client.ITestCase newTestCase = obj.TestCase;

                if (newTestCase == null)
                {
                    newTestCase             = selectedProject.TestCases.Create();
                    newTestCase.Title       = testCase.Name;
                    newTestCase.Description = "<p><strong>Summary</strong></p>" + testCase.Description + "<p><strong>Pre Conditions</strong></p>" + testCase.PreConditions;
                    var link = new Hyperlink(testCase.LinkInTestLink);
                    newTestCase.Links.Add(link);
                    newTestCase.Priority = testCase.Importance;
                    newTestCase.CustomFields["Assigned To"].Value = string.Empty;

                    LoadTestSteps(testCase, newTestCase);

                    newTestCase.Save();

                    suitcollection.Add(newTestCase);
                }
                else
                {
                    if (newTestCase.Actions.Count != testCase.Steps.Count)
                    {
                        TestCaseConflict tcc = new TestCaseConflict();
                        tcc.Message     = testCase.Name + " (-:-) already exists and has a different step count" + Environment.NewLine + "(" + testCase.LinkInTestLink + ")";
                        tcc.TestCase    = testCase;
                        tcc.TfsTestCase = newTestCase;
                        if (throwExceptionIfTestCaseConflicts)
                        {
                            throw new TestCaseConflictException(tcc);
                        }
                        result.Add(tcc);
                    }
                    else
                    {
                        string differntFields = string.Empty;
                        for (int pos = 0; pos < testCase.Steps.Count; pos++)
                        {
                            if (HtmlRemovalUtility.StripTagsCharArrayWithExtraParsing(((ITestStep)newTestCase.Actions[pos]).Description) != HtmlRemovalUtility.StripTagsCharArrayWithExtraParsing(testCase.Steps[pos].Actions))
                            {
                                differntFields += "\t[" + pos + "] Description : " + testCase.Steps[pos].Actions + Environment.NewLine;
                            }
                            if (HtmlRemovalUtility.StripTagsCharArrayWithExtraParsing(((ITestStep)newTestCase.Actions[pos]).ExpectedResult) != HtmlRemovalUtility.StripTagsCharArrayWithExtraParsing(testCase.Steps[pos].ExpectedResults))
                            {
                                differntFields += "\t[" + pos + "] ExpectedResults : " + testCase.Steps[pos].ExpectedResults + Environment.NewLine;
                            }
                        }
                        if (differntFields.Length > 0)
                        {
                            TestCaseConflict tcc = new TestCaseConflict();
                            tcc.Message     = testCase.Name + " (-:-) already exists and is different" + Environment.NewLine + "(" + testCase.LinkInTestLink + ")" + Environment.NewLine + differntFields;
                            tcc.TestCase    = testCase;
                            tcc.TfsTestCase = newTestCase;
                            if (throwExceptionIfTestCaseConflicts)
                            {
                                throw new TestCaseConflictException(tcc);
                            }
                            result.Add(tcc);
                        }
                    }
                }
            }

            return(result);
        }