Ejemplo n.º 1
0
        private void ParseControlFile(string testCaseNamePrefix, string controlFile, string[] filters, string defaultSection, XElement topNode, MyDict <string, object> masterList, IList xmlDriverParams)
        {
            // load the control file
            XDocument doc = LoadControlFile(controlFile);

            // parse test module top node
            XElement testModuleNode = doc.Element("TestModule");

            AddBuiltInAttributes(testModuleNode);
            XElement testModuleVirtualNode = (topNode == null) ? testModuleNode :
                                             BuildVirtualNode(new XElement(topNode), testModuleNode);
            string testModuleName        = SelectExistingAttributeValue(testModuleNode, "Name");
            string testModuleCreated     = SelectExistingAttributeValue(testModuleNode, "Created");
            string testModuleModified    = SelectExistingAttributeValue(testModuleNode, "Modified");
            string testModuleDescription = SelectDescription(testModuleNode);

            CXmlDriverParamRawNodes testModuleParam = new CXmlDriverParamRawNodes_TestModule(testModuleNode, testModuleVirtualNode, null);

            xmlDriverParams.Add(new CXmlDriverParam(testModuleParam, defaultSection));

            // process includes
            ProcessIncludes(filters, defaultSection, testModuleNode, masterList, xmlDriverParams);

            // filter xPath
            string filterXPath = CombineXPath(filters);

            // loop through all test cases
            foreach (XElement testCaseNode in testModuleNode.Elements("TestCase"))
            {
                string testCaseName = SelectExistingAttributeValue(testCaseNode, "Name");
                if (testCaseNamePrefix != null && testCaseNamePrefix != "")
                {
                    testCaseName = testCaseNamePrefix + "_" + testCaseName;
                }
                string testCaseDescription = SelectDescription(testCaseNode);

                XElement testCaseVirtualNode          = null;
                CXmlDriverParamRawNodes testCaseParam = new CXmlDriverParamRawNodes_TestCase(testCaseNode, testCaseVirtualNode, testModuleParam);

                // create a test case class
                CTestCase testCase = CreateTestCase(testCaseName, testCaseDescription, new CXmlDriverParam(testCaseParam, defaultSection));

                // loop through all variations
                int varCount    = 0;
                int actVarCount = 0;
                foreach (XElement varNode in testCaseNode.Elements("Variation"))
                {
                    varCount++;
                    string   varId          = SelectExistingAttributeValue(varNode, "Id");
                    string   varName        = SelectName(varNode);
                    string   varPri         = SelectPriority(varNode);
                    XElement varVirtualNode = null;

                    // check filter
                    CXmlDriverParamRawNodes varParam = new CXmlDriverParamRawNodes_Variation(varNode, varVirtualNode, testCaseParam);
                    if (!CheckFilter(varParam, filterXPath))
                    {
                        continue;
                    }

                    // create a new variation and add it to the current testCase
                    actVarCount++;
                    string varDescription   = SelectDescription(varNode);
                    CXmlDriverVariation var = new CXmlDriverVariation((CXmlDriverScenario)testCase,
                                                                      varName, varDescription, Int32.Parse(varId), Int32.Parse(varPri),
                                                                      new CXmlDriverParam(varParam, defaultSection));
                    testCase.AddVariation(var);
                }

                if (actVarCount == 0 && varCount > 0)
                {
                    // no 'implemented' variations satisfying the filter
                    testCase = new CXmlDriverEmptyTestCase(testCaseName, testCaseDescription,
                                                           " no variations with @Implemented='True' " +
                                                           (_requiredLanguage != null && _requiredLanguage.Length != 0 ? " and @Language='" + _requiredLanguage + "'" : "") +
                                                           (filterXPath == null ? "" : " and satisfying '" + filterXPath + "'"), _testModule);
                }

                // add test case
                _testModule.AddTestCase(testCase);
            }
        }
Ejemplo n.º 2
0
        private void ParseControlFile(string testCaseNamePrefix, string controlFile, string[] filters, string defaultSection, XElement topNode, MyDict<string, object> masterList, IList xmlDriverParams)
        {
            // load the control file
            XDocument doc = LoadControlFile(controlFile);

            // parse test module top node
            XElement testModuleNode = doc.Element("TestModule");
            AddBuiltInAttributes(testModuleNode);
            XElement testModuleVirtualNode = (topNode == null) ? testModuleNode :
                BuildVirtualNode(new XElement(topNode), testModuleNode);
            string testModuleName = SelectExistingAttributeValue(testModuleNode, "Name");
            string testModuleCreated = SelectExistingAttributeValue(testModuleNode, "Created");
            string testModuleModified = SelectExistingAttributeValue(testModuleNode, "Modified");
            string testModuleDescription = SelectDescription(testModuleNode);

            CXmlDriverParamRawNodes testModuleParam = new CXmlDriverParamRawNodes_TestModule(testModuleNode, testModuleVirtualNode, null);
            xmlDriverParams.Add(new CXmlDriverParam(testModuleParam, defaultSection));

            // process includes
            ProcessIncludes(filters, defaultSection, testModuleNode, masterList, xmlDriverParams);

            // filter xPath 
            string filterXPath = CombineXPath(filters);

            // loop through all test cases
            foreach (XElement testCaseNode in testModuleNode.Elements("TestCase"))
            {
                string testCaseName = SelectExistingAttributeValue(testCaseNode, "Name");
                if (testCaseNamePrefix != null && testCaseNamePrefix != "")
                    testCaseName = testCaseNamePrefix + "_" + testCaseName;
                string testCaseDescription = SelectDescription(testCaseNode);

                XElement testCaseVirtualNode = null;
                CXmlDriverParamRawNodes testCaseParam = new CXmlDriverParamRawNodes_TestCase(testCaseNode, testCaseVirtualNode, testModuleParam);

                // create a test case class
                CTestCase testCase = CreateTestCase(testCaseName, testCaseDescription, new CXmlDriverParam(testCaseParam, defaultSection));

                // loop through all variations
                int varCount = 0;
                int actVarCount = 0;
                foreach (XElement varNode in testCaseNode.Elements("Variation"))
                {
                    varCount++;
                    string varId = SelectExistingAttributeValue(varNode, "Id");
                    string varName = SelectName(varNode);
                    string varPri = SelectPriority(varNode);
                    XElement varVirtualNode = null;

                    // check filter
                    CXmlDriverParamRawNodes varParam = new CXmlDriverParamRawNodes_Variation(varNode, varVirtualNode, testCaseParam);
                    if (!CheckFilter(varParam, filterXPath))
                        continue;

                    // create a new variation and add it to the current testCase 
                    actVarCount++;
                    string varDescription = SelectDescription(varNode);
                    CXmlDriverVariation var = new CXmlDriverVariation((CXmlDriverScenario)testCase,
                        varName, varDescription, Int32.Parse(varId), Int32.Parse(varPri),
                        new CXmlDriverParam(varParam, defaultSection));
                    testCase.AddVariation(var);
                }

                if (actVarCount == 0 && varCount > 0)
                    // no 'implemented' variations satisfying the filter
                    testCase = new CXmlDriverEmptyTestCase(testCaseName, testCaseDescription,
                        " no variations with @Implemented='True' " +
                        (_requiredLanguage != null && _requiredLanguage.Length != 0 ? " and @Language='" + _requiredLanguage + "'" : "") +
                        (filterXPath == null ? "" : " and satisfying '" + filterXPath + "'"), _testModule);

                // add test case
                _testModule.AddTestCase(testCase);
            }
        }