public ObservableList <RQMExecutionRecord> GetExecutionRecordsByTestPlan(LoginDTO loginData, XmlReader reader, RQMProject currentRQMProjectMapping, string currentProjPrefix, string currentProjGuid, string testPlanURLPathVersioned) { ObservableList <RQMExecutionRecord> RQMExecutionRecords = new ObservableList <RQMExecutionRecord>(); RqmResponseData responseDataExecutionRecords = RQMRep.GetExecutionByTestPlan(loginData, currentProjPrefix, currentProjGuid, testPlanURLPathVersioned); XmlDocument docExecutionRecords = new XmlDocument(); docExecutionRecords.LoadXml(responseDataExecutionRecords.responseText.ToString()); XmlNamespaceManager nsmgrExecutionRecords = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrExecutionRecords.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNodeExecutionRecords = docExecutionRecords.DocumentElement; XmlNodeList executionRecords = responseDataNodeExecutionRecords.SelectNodes(currentRQMProjectMapping.RQMExecutionRecordsMapping.PathXML, nsmgrExecutionRecords); foreach (XmlNode executionRecord in executionRecords) { try { string curentExecutionRecordUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RelatedTestCaseUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); RqmResponseData responseDataVersionedTC = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordUri)); XmlDocument docVersionedTC = new XmlDocument(); docVersionedTC.LoadXml(responseDataVersionedTC.responseText.ToString()); XmlNode responseDataNodeVersionedTC = docVersionedTC.DocumentElement; RqmResponseData responseDataVersionedTS; try { string curentExecutionRecordScriptUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.ExecutesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri)); } catch { string curentExecutionRecordScriptUri = responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.UsesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri)); } XmlDocument docVersionedTS = new XmlDocument(); docVersionedTS.LoadXml(responseDataVersionedTS.responseText.ToString()); XmlNode responseDataNodeVersionedTS = docVersionedTS.DocumentElement; if (RQMExecutionRecords.Where(x => x.RQMID == executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString()).ToList().Count == 0) { RQMExecutionRecord rQMExecutionRecord = new RQMExecutionRecord(executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString(), responseDataNodeVersionedTS.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestScriptXmlPathToID, nsmgrExecutionRecords).InnerText.ToString(), responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestCaseXmlPathToID, nsmgrExecutionRecords).InnerText.ToString()); RQMExecutionRecords.Add(rQMExecutionRecord); } } catch { } } return(RQMExecutionRecords); }
public ObservableList <RQMExecutionRecord> GetTestSuiteCurrentResult(LoginDTO loginData, XmlReader reader, RQMProject currentRQMProjectMapping, string currentProjPrefix, string currentProjGuid, string currentTestSuiteResultUri) { if ((currentTestSuiteResultUri == null) || (currentTestSuiteResultUri == string.Empty)) { return(null); } ObservableList <RQMExecutionRecord> RQMExecutionRecords = new ObservableList <RQMExecutionRecord>(); RqmResponseData responseDataCurrentTestSuiteResult = RQMRep.GetRqmResponse(loginData, new Uri(currentTestSuiteResultUri)); XmlDocument docTestSuiteResult = new XmlDocument(); docTestSuiteResult.LoadXml(responseDataCurrentTestSuiteResult.responseText.ToString()); XmlNamespaceManager nsmgrTestSuiteResult = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestSuiteResultsMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTestSuiteResult.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseTestSuiteResult = docTestSuiteResult.DocumentElement; XmlNodeList executionRecordsURIs = responseTestSuiteResult.SelectNodes(currentRQMProjectMapping.RQMTestSuiteResultsMapping.XMLPathToResultsExecutionRecordsList, nsmgrTestSuiteResult); XmlNamespaceManager nsmgrExecutionRecords = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrExecutionRecords.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); foreach (XmlNode executionRecordURI in executionRecordsURIs) { try { RqmResponseData responseDataExecutionRecord = RQMRep.GetRqmResponse(loginData, new Uri(executionRecordURI.Attributes[0].InnerText.ToString())); XmlDocument docExecutionRecords = new XmlDocument(); docExecutionRecords.LoadXml(responseDataExecutionRecord.responseText.ToString()); XmlNode responseDataNodeExecutionRecord = docExecutionRecords.DocumentElement; XmlNode executionRecord = responseDataNodeExecutionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.XMLPathOfSingleSelectionCase, nsmgrExecutionRecords); string curentExecutionRecordVersionedTCUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RelatedTestCaseUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); RqmResponseData responseDataVersionedTC = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordVersionedTCUri)); XmlDocument docVersionedTC = new XmlDocument(); docVersionedTC.LoadXml(responseDataVersionedTC.responseText.ToString()); XmlNode responseDataNodeVersionedTC = docVersionedTC.DocumentElement; RqmResponseData responseDataVersionedTS; try { string curentExecutionRecordScriptUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.ExecutesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri)); } catch { string curentExecutionRecordScriptUri = responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.UsesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString(); responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri)); } XmlDocument docVersionedTS = new XmlDocument(); docVersionedTS.LoadXml(responseDataVersionedTS.responseText.ToString()); XmlNode responseDataNodeVersionedTS = docVersionedTS.DocumentElement; if (RQMExecutionRecords.Where(x => x.RQMID == executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString()).ToList().Count == 0) { RQMExecutionRecord rQMExecutionRecord = new RQMExecutionRecord(executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString(), responseDataNodeVersionedTS.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestScriptXmlPathToID, nsmgrExecutionRecords).InnerText.ToString(), responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestCaseXmlPathToID, nsmgrExecutionRecords).InnerText.ToString()); RQMExecutionRecords.Add(rQMExecutionRecord); } } catch { } } return(RQMExecutionRecords); }
public ObservableList <RQMTestCase> BuildRQMTestCaseList(XmlNodeList testCases, XmlNamespaceManager nsmgr, LoginDTO loginData, RQMProject currentRQMProjectMapping, XmlReader reader, string TestSuiteTitle, string TestSuiteId) { ObservableList <RQMTestCase> RQMTestCaseList = new ObservableList <RQMTestCase>(); foreach (XmlNode testCase in testCases) { RqmResponseData responseDataTC = RQMRep.GetRqmResponse(loginData, new Uri(testCase.Attributes[0].InnerText.ToString())); XmlDocument doc = new XmlDocument(); XmlDocument docTC = new XmlDocument(); doc.LoadXml(responseDataTC.responseText.ToString()); nsmgr = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestCaseMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgr.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNodeTC = doc.DocumentElement; RQMTestCase rQMTestCase = new RQMTestCase(responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.Name, nsmgr).InnerText.ToString(), responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.RQMID, nsmgr).InnerText.ToString(), responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.Description, nsmgr).InnerText.ToString(), responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.CreatedBy, nsmgr).Attributes[0].InnerText.Split('/').Last().ToString(), DateTime.Parse(responseDataNodeTC.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.CreationDate, nsmgr).InnerText.ToString()).ToLocalTime(), TestSuiteTitle, TestSuiteId); try { XmlNodeList variables = responseDataNodeTC.SelectNodes(currentRQMProjectMapping.RQMTestCaseMapping.XMLPathToVariablesList, nsmgr); foreach (XmlNode variable in variables) { // looking for specific Variable from BTS if (variable.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.VariableName, nsmgr).InnerText.ToString() == BTS_ACTIVITY_ID) { rQMTestCase.BTSID = variable.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.VariableValue, nsmgr).InnerText.ToString(); continue; } RQMTestParameter rQMTestParameter; rQMTestParameter = new RQMTestParameter(variable.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.VariableName, nsmgr).InnerText.ToString(), variable.SelectSingleNode(currentRQMProjectMapping.RQMTestCaseMapping.VariableValue, nsmgr).InnerText.ToString()); rQMTestCase.Parameters.Add(rQMTestParameter); } } catch { } XmlNodeList testScripts = responseDataNodeTC.SelectNodes(currentRQMProjectMapping.RQMTestCaseMapping.PathXML, nsmgr); foreach (XmlNode testScript in testScripts) { RqmResponseData responseDataTestScript = RQMRep.GetRqmResponse(loginData, new Uri(testScript.Attributes[0].InnerText.ToString())); doc.LoadXml(responseDataTestScript.responseText.ToString()); nsmgr = new XmlNamespaceManager(reader.NameTable); currentRQMProjectMapping.RQMTestScriptMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgr.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName)); XmlNode responseDataNodeTestScript = doc.DocumentElement; RQMTestScript newRQMTestScript = new RQMTestScript(responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.Name, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.RQMID, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.Description, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.CreatedBy, nsmgr).Attributes[0].InnerText.Split('/').Last().ToString(), DateTime.Parse(responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.CreationDate, nsmgr).InnerText.ToString()).ToLocalTime()); try { XmlNodeList variables = responseDataNodeTestScript.SelectNodes(currentRQMProjectMapping.RQMTestScriptMapping.XMLPathToVariablesList, nsmgr); foreach (XmlNode variable in variables) { // looking for specific Variable from BTS if (variable.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.VariableName, nsmgr).InnerText.ToString() == BTS_ACTIVITY_STEPS_ID) { newRQMTestScript.BTSStepsIDs = variable.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.VariableValue, nsmgr).InnerText.ToString(); continue; } RQMTestParameter rQMTestParameter; rQMTestParameter = new RQMTestParameter(variable.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.VariableName, nsmgr).InnerText.ToString(), variable.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.VariableValue, nsmgr).InnerText.ToString()); newRQMTestScript.Parameters.Add(rQMTestParameter); } } catch { } XmlNodeList steps = responseDataNodeTestScript.SelectNodes(currentRQMProjectMapping.RQMTestScriptMapping.PathXML, nsmgr); foreach (XmlNode step in steps) { RQMStep newStep; try { newStep = new RQMStep(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.Name, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.RQMID, nsmgr).InnerText.ToString() + "_" + step.Attributes[0].InnerText.ToString(), ImportFromRQM.StripHTML(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.Description, nsmgr).InnerText.ToString()), ImportFromRQM.StripHTML(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.ExpectedResult, nsmgr).InnerText.ToString())); newRQMTestScript.Steps.Add(newStep); } catch { try { newStep = new RQMStep(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.Name, nsmgr).InnerText.ToString(), responseDataNodeTestScript.SelectSingleNode(currentRQMProjectMapping.RQMTestScriptMapping.RQMID, nsmgr).InnerText.ToString() + "_" + step.Attributes[0].InnerText.ToString(), ImportFromRQM.StripHTML(step.SelectSingleNode(currentRQMProjectMapping.RQMStepMapping.Description, nsmgr).InnerText.ToString()), string.Empty); newRQMTestScript.Steps.Add(newStep); } catch { } } } rQMTestCase.TestScripts.Add(newRQMTestScript); if (rQMTestCase.TestScripts.Count > 0) { rQMTestCase.SelectedTestScriptName = rQMTestCase.TestScripts[0].Name.ToString(); } } RQMTestCaseList.Add(rQMTestCase); } return(RQMTestCaseList); }