Esempio n. 1
0
        private static List <ITestCase> GetTestCasesFrom(XmlNode testSuiteNode)
        {
            var result = new List <ITestCase>();

            XmlNodeList xmlNodeList = testSuiteNode.SelectNodes("testcase");

            if (xmlNodeList != null)
            {
                foreach (XmlNode testCaseNode in xmlNodeList)
                {
                    string    nameOriginal = GetAttributeValueAsString(testCaseNode, "name");
                    ITestCase testCase     = result.Where(o => string.Compare(o.Name, nameOriginal, System.StringComparison.OrdinalIgnoreCase) == 0).FirstOrDefault();

                    if (testCase == null)
                    {
                        string name = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(GetAttributeValueAsString(testCaseNode, "name")));
                        testCase = TestCaseFactory.CreateDefaultTestCase();
                        if (nameOriginal != name)
                        {
                            testCase.Name = name + " - " + Guid.NewGuid().ToString("N");
                        }
                        else
                        {
                            testCase.Name = name;
                        }

                        testCase.InternalID     = GetAttributeValueAsInt32(testCaseNode, "internalid");
                        testCase.NodeCount      = SelectAndReadNodeTextAsInt32(testCaseNode, "node_order");
                        testCase.ExternalID     = SelectAndReadNodeTextAsInt32(testCaseNode, "externalid");
                        testCase.LinkInTestLink = "http://<Server><Virtual Directory>/linkto.php?tprojectPrefix=C&item=testcase&id=C-" + testCase.ExternalID;
                        testCase.Version        = SelectAndReadNodeTextAsInt32(testCaseNode, "version");
                        testCase.Description    = SelectAndReadNodeTextAsString(testCaseNode, "summary");
                        testCase.PreConditions  = SelectAndReadNodeTextAsString(testCaseNode, "preconditions");
                        testCase.ExecutionType  = SelectAndReadNodeTextAsInt32(testCaseNode, "execution_type");
                        testCase.Importance     = SelectAndReadNodeTextAsInt32(testCaseNode, "importance");
                        testCase.Steps          = GetTestCaseStepsFrom(testCaseNode.SelectSingleNode("steps"));
                        result.Add(testCase);
                    }
                }
            }


            return(result);
        }