// Case 1643: 1.1.03.12_List Objects - N10 - tag for image with logicon report public void Run_Patient_ListObjects_LogiconTagForImage_Case1643() { int runCount = 0; PatientService oldPatientSvc = new PatientService(); ImportService ims = new ImportService(); NewPatientService patientSvc = new NewPatientService(); PatientListObjectsRequestType pListObjects = new PatientListObjectsRequestType(); PatientListObjectsResponseType rtListObjects = new PatientListObjectsResponseType(); PatientListObjectsResponseType rtListObjectsAfterProcess = new PatientListObjectsResponseType(); foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { #region Initialize test data XMLParameter pCreatePatient = new XMLParameter("patient"); string patientID = string.Empty; string filePath = string.Empty; string archivePath = string.Empty; string imageID = string.Empty; for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "createPatient") { pCreatePatient.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } else if (ids.InputParameters.GetParameter(i).Step == "import") { if (ids.InputParameters.GetParameter(i).Key == "filePath") { filePath = ids.InputParameters.GetParameter(i).Value; } else if (ids.InputParameters.GetParameter(i).Key == "archivePath") { archivePath = ids.InputParameters.GetParameter(i).Value; } } } string tagBeforeProcess = null; string tagAfterProcess = null; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "listObjectsBeforeProcess") { tagBeforeProcess = ids.ExpectedValues.GetParameter(i).Value; } else if (ids.ExpectedValues.GetParameter(i).Step == "listObjectsAfterProcess") { tagAfterProcess = ids.ExpectedValues.GetParameter(i).Value; } } #endregion #region Step: Create a patient CheckPoint cpCreate = new CheckPoint("Create Patient", "Create Patient"); r.CheckPoints.Add(cpCreate); XMLResult rtCreatePatient = oldPatientSvc.createPatient(pCreatePatient); if (rtCreatePatient.IsErrorOccured) { cpCreate.Result = TestResult.Fail; cpCreate.Outputs.AddParameter("Create returns error:", "Create Patient", rtCreatePatient.Message); SaveRound(r); continue; } else { patientID = rtCreatePatient.SingleResult; pListObjects.patientInternalId = patientID; pListObjects.current = true; pListObjects.currentSpecified = true; cpCreate.Outputs.AddParameter("Patient ID:", "Create Patient", rtCreatePatient.SingleResult); cpCreate.Result = TestResult.Pass; } #endregion #region Step: Prepare a RVG image CheckPoint cpImport = new CheckPoint("Import Image", "Test import"); r.CheckPoints.Add(cpImport); XMLResult rtlImport = ims.importObject(patientID, "", filePath, archivePath, false, "false"); if (rtlImport.IsErrorOccured) { cpImport.Result = TestResult.Fail; cpImport.Outputs.AddParameter("import", "Import image fail", rtlImport.ResultContent); } else { cpImport.Result = TestResult.Pass; cpImport.Outputs.AddParameter("import", "Import image OK", rtlImport.ResultContent); imageID = rtlImport.SingleResult; } #endregion #region Step: Check the tag before do logicon processing CheckPoint cpListObjects = new CheckPoint("List Object", "List Object before process"); r.CheckPoints.Add(cpListObjects); rtListObjects = patientSvc.listObjects(pListObjects); if (patientSvc.LastReturnXMLValidateResult.isValid && rtListObjects.status.code == 0) { cpListObjects.Result = TestResult.Pass; cpListObjects.Outputs.AddParameter("List Object Return Pass", "List Object", "The web service return is OK!: " + patientSvc.LastReturnXML); } else { cpListObjects.Result = TestResult.Fail; cpListObjects.Outputs.AddParameter("List Object Return Fail", "List Object", "The web service return is ERROR! : " + patientSvc.LastReturnXML); goto CLEANUP; } CheckPoint cpLogiconTag = new CheckPoint("Tag", "Check the logicon tag before processing"); if (tagBeforeProcess == rtListObjects.presentationStates[0].image.tags) { cpLogiconTag.Outputs.AddParameter("Check Tag", "List Object", "List Object return tag as expect: " + patientSvc.LastReturnXML); cpLogiconTag.Result = TestResult.Pass; } else { cpLogiconTag.Outputs.AddParameter("List Object Return Result unexpect", "List Object", "List Object return unexpected tag!" + patientSvc.LastReturnXML); cpLogiconTag.Result = TestResult.Fail; } #endregion #region Step: Do logicon processing GenericInstanceService genericInstanceSvc = new GenericInstanceService(); genericInstanceSvc.DoLogiconProcess(r, imageID); #endregion #region Step: Check the tag after do logicon processing CheckPoint cpListObjectsAfterProcess = new CheckPoint("List Object", "List Object after process"); r.CheckPoints.Add(cpListObjectsAfterProcess); rtListObjectsAfterProcess = patientSvc.listObjects(pListObjects); if (patientSvc.LastReturnXMLValidateResult.isValid && rtListObjectsAfterProcess.status.code == 0) { cpListObjectsAfterProcess.Result = TestResult.Pass; cpListObjectsAfterProcess.Outputs.AddParameter("List Object Return Pass", "List Object", "The web service return is OK!"); } else { cpListObjectsAfterProcess.Result = TestResult.Fail; cpListObjectsAfterProcess.Outputs.AddParameter("List Object Return Fail", "List Object", "The web service return is ERROR! : " + patientSvc.LastReturnXML); goto CLEANUP; } CheckPoint cpLogiconTagAfterProcess = new CheckPoint("Tag", "Check the logicon tag before processing"); if (tagAfterProcess == rtListObjectsAfterProcess.presentationStates[0].image.tags) { cpListObjectsAfterProcess.Outputs.AddParameter("Check Tag", "List Object", "List Object return tag as expect: " + patientSvc.LastReturnXML); cpListObjectsAfterProcess.Result = TestResult.Pass; } else { cpListObjectsAfterProcess.Outputs.AddParameter("List Object Return Result unexpect", "List Object", "List Object return unexpected tag!" + patientSvc.LastReturnXML); cpListObjectsAfterProcess.Result = TestResult.Fail; } #endregion #region Delete patient CLEANUP: CheckPoint cpDelete = new CheckPoint("Delete Patient", "Delete Patient"); r.CheckPoints.Add(cpDelete); XMLResult rtDeletePatient = oldPatientSvc.deletePatient(patientID); if (rtDeletePatient.IsErrorOccured) { cpDelete.Result = TestResult.Fail; cpDelete.Outputs.AddParameter("Delete returns error:", "Delete Patient", rtDeletePatient.Message); } else { cpDelete.Outputs.AddParameter("Delete return success:", "Delete Patient", rtDeletePatient.Message); cpDelete.Result = TestResult.Pass; } #endregion SaveRound(r); } catch (Exception ex) { CheckPoint cp = new CheckPoint(); r.CheckPoints.Add(cp); cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message); cp.Result = TestResult.Fail; SaveRound(r); } } Output(); }
// Case 1657: 1.1.05.06_Call listInstances to volume to list child and slibling public void Run_GenericInstance_ListInstances_Case1657() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "List Instances"); CheckPoint listCheck = new CheckPoint("List Instances", "Test description"); r.DataSet = ids; r.CheckPoints.Add(listCheck); GenericInstanceService instances = new GenericInstanceService(); XMLParameter pa = new XMLParameter("filter"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "listInstances") { pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } XMLResult result = instances.listInstances(pa); if (result.IsErrorOccured) { listCheck.Result = TestResult.Fail; listCheck.Outputs.AddParameter("listInstances fail", "list Instances", result.Message); } else { listCheck.Outputs.AddParameter("listInstances OK", "list Instances", result.ResultContent); System.Xml.XmlDocument xmlResult = new System.Xml.XmlDocument(); xmlResult.LoadXml(result.ResultContent); System.Xml.XmlNodeList instanceList = xmlResult.SelectNodes("trophy/instance/parameter"); listCheck.Result = TestResult.Pass; List<int> findedGroup = new List<int>(); int nodeIndex = 0; foreach (System.Xml.XmlNode instance in instanceList) { int matchStep = 0; nodeIndex++; foreach (Parameter pExpected in ids.ExpectedValues.Parameters) { int iExpIdx = 0; if (System.Int32.TryParse(pExpected.Step, out iExpIdx)) { if (pExpected.Key == "value" && pExpected.Value == instance.Attributes["value"].Value ) matchStep = iExpIdx; } } if (matchStep > 0) { bool matchKey = false; bool matchParentID = false; foreach (Parameter pExpected in ids.ExpectedValues.Parameters) { int iExpIdx = 0; if (System.Int32.TryParse(pExpected.Step, out iExpIdx)) { if (pExpected.Key == "key" && pExpected.Value == instance.Attributes["key"].Value && iExpIdx == matchStep ) matchKey = true; else if (pExpected.Key == "parent_id" && pExpected.Value == instance.Attributes["parent_id"].Value && iExpIdx == matchStep ) matchParentID = true; } } if (matchKey && matchParentID) { } else { listCheck.Result = TestResult.Fail; string key = nodeIndex + " key or parent id unmatched"; listCheck.Outputs.AddParameter("listInstances", key, instance.OuterXml); } findedGroup.Add(matchStep); } else { listCheck.Result = TestResult.Fail; string key = nodeIndex + " fail to find the instance in expected results"; listCheck.Outputs.AddParameter("listInstances", key, instance.InnerXml); } } foreach (Parameter pExpected in ids.ExpectedValues.Parameters) { int iExpIdx = 0; if (System.Int32.TryParse(pExpected.Step, out iExpIdx)) { if (pExpected.Key == "value") { bool bfinded = false; foreach (int matchStep in findedGroup) { if (iExpIdx == matchStep) { bfinded = true; break; } } if (bfinded) { } else { listCheck.Result = TestResult.Fail; string key = iExpIdx + " fail to find the instance in expected results"; listCheck.Outputs.AddParameter("listInstances", key, pExpected.Value); } } } } } SaveRound(r); } Output(); }