public void Run_Acquisition_New_Ceph_4_Case1672() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; string acquireType = string.Empty; Round r = this.NewRound(runCount.ToString(), "Acquisition"); ApplicationService apps = new ApplicationService(); //start 2D simulator and register 2D simulator to CSDM with same port number Start2DSimulator s2d = new Start2DSimulator(10000); System.Threading.Thread.Sleep(20); apps.registerApplication("2DViewer", "localhost", 10000, true); //get acquire information and expect information XMLParameter acq = new XMLParameter("acq_info"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "acquire") { acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "acquireType") { acquireType = ids.InputParameters.GetParameter(i).Key; } } Dictionary<string, string> expectVal = new Dictionary<string, string>(); for (int j = 0; j < ids.ExpectedValues.Count; j++) { if (ids.InputParameters.GetParameter(j).Step == "acquire") { expectVal.Add(ids.ExpectedValues.GetParameter(j).Key, ids.ExpectedValues.GetParameter(j).Value); } } CheckPoint pAcquire = new CheckPoint("Acquire Image", "Acquisition RVG"); r.CheckPoints.Add(pAcquire); System.Diagnostics.Debug.Print("Acquire start"); string stopMessageType = "teststop"; string stopMessageContent = "teststop"; string hostadd = PAS.AutoTest.TestUtility.Utility.GetCSDMConfig(PAS.AutoTest.TestUtility.CSDMConfigSection.remote, "host"); string portnoti = PAS.AutoTest.TestUtility.Utility.GetCSDMConfig(PAS.AutoTest.TestUtility.CSDMConfigSection.remote, "notificationPort"); NotificationSim.ReceiveNotification rn = new NotificationSim.ReceiveNotification(hostadd, int.Parse(portnoti)); System.Collections.Generic.List<string> rms = new System.Collections.Generic.List<string>(); rms.Add("topic.acquisitionCompleted"); rn.startListon(rms, stopMessageType, stopMessageContent); AcquisitionService acqs = new AcquisitionService(); XMLResult rslAcqRVG = acqs.startAcquisition(acq); string acq_session_id = ""; System.Threading.Thread.Sleep(1000); switch (acquireType) { case "PANO": System.Diagnostics.Debug.Print("PANO Acquire"); //Utility.AcqPanoImage(300); System.Threading.Thread tx = new System.Threading.Thread(Utility.AcquirePanoOne); tx.Start(); break; case "CEPH": System.Diagnostics.Debug.Print("CEPH Acquire"); //Utility.AcqCephImage(50); System.Threading.Thread tx1 = new System.Threading.Thread(Utility.AcquireCephOne); tx1.Start(); break; default: System.Diagnostics.Debug.Print("NOT FMS/PANO/CEPH/CR Acquire"); break; } if (rslAcqRVG.IsErrorOccured) { System.Diagnostics.Debug.Print("Acquire fail:"); pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcqRVG.Message); continue; } else { acq_session_id = rslAcqRVG.SingleResult; pAcquire.Result = TestResult.Pass; pAcquire.Outputs.AddParameter("Acquire image success", "startAcquisition", rslAcqRVG.ResultContent); //start an advanced simulator to receive the specified command int port = 10000; string sRet = ""; TwoDSim.AdvanceSimulator asi = new TwoDSim.AdvanceSimulator(port); asi.StartSimulater("0,OK;open_acquired_objects"); sRet = asi.StopSimulator(120000); CheckPoint pCheckMessage = new CheckPoint("Check Command", "Acquisition SOCKET Message"); r.CheckPoints.Add(pCheckMessage); if (sRet == "") { pCheckMessage.Result = TestResult.Fail; pCheckMessage.Outputs.AddParameter("NO COMMAND", "Check Command", "TIMEOUT: The socket message doesn't received"); SaveRound(r); continue; } else { pCheckMessage.Outputs.AddParameter("open_acquired_objects COMMAND parameter", "Record Command", sRet); } ParseMessageContent cn = new ParseMessageContent(sRet); //get patient internal id from command message string patient_uid = cn.getValueFromKey("-patient_internal_id"); bool gotPatientId = false; foreach (KeyValuePair<string, string> kvp in expectVal) { if (kvp.Key == "patient_internal_id" && kvp.Value == patient_uid) { gotPatientId = true; } } if (!gotPatientId) { pCheckMessage.Result = TestResult.Fail; pCheckMessage.Outputs.AddParameter("Patient ID Check ERROR", "Check Command", "The socket message content with WRONG patient ID"); SaveRound(r); continue; } string image_internal_id_from_acqResult = ""; string ps_internal_id_from_acqResult = ""; string image_internal_id_from_mapfile = ""; string ps_internal_id_from_mapfile = ""; //get acquisition session id from command message string session_uid_from_command = cn.getValueFromKey("-session_id"); if (acq_session_id != session_uid_from_command) { pCheckMessage.Result = TestResult.Fail; pCheckMessage.Outputs.AddParameter("Session ID Check ERROR", "Check Command", "The session id from command not equals the id from startAcquisition!"); SaveRound(r); continue; } int timeout = 0; do { XMLResult rslgetAcqResult = acqs.getAcquisitionResult(session_uid_from_command); //timeout added if (!rslgetAcqResult.IsErrorOccured && rslgetAcqResult.Code == 0) { pCheckMessage.Outputs.AddParameter("Show the content after getAcquisitionResult", "Output getAcquisitionResult", rslgetAcqResult.ResultContent); ParseXMLContent rslacqResult = new ParseXMLContent(rslgetAcqResult.ResultContent); image_internal_id_from_acqResult = rslacqResult.getStringWithPathAndType("trophy/object_info", "image", "value"); ps_internal_id_from_acqResult = rslacqResult.getStringWithPathAndType("trophy/object_info", "presentation_state", "value"); break; } timeout++; System.Threading.Thread.Sleep(1000); } while (timeout < 120); if (timeout >= 120) { pCheckMessage.Result = TestResult.Fail; pCheckMessage.Outputs.AddParameter("Try too many times", "Check getAcquisitionResult", "TIMEOUT of getAcquisitionResult"); break; } //parser the mapping xml content from command message string mapping_xml = cn.getValueFromKey("-mapping_xml"); string mapping_content = base64tools.DecodeString4base(mapping_xml); pCheckMessage.Outputs.AddParameter("Show the decode mapping file content", "Output mappingfile", mapping_content); string target_path = ""; if (mapping_content != null) { ParseXMLContent pc = new ParseXMLContent(mapping_content); pc.getValueFromPath("path_mapping/instance"); string type = pc.getValueByKey("type"); int indexKey = type.IndexOf(";"); if (indexKey != -1) type = type.Substring(0, indexKey); bool gotType = false; foreach (KeyValuePair<string, string> kvp in expectVal) { if (kvp.Key == "type" && kvp.Value == type) { gotType = true; } } if (!gotType) { pCheckMessage.Result = TestResult.Fail; pCheckMessage.Outputs.AddParameter("Type Check ERROR", "Check Command ", "The socket message content with WRONG type"); SaveRound(r); continue; } string original_path = pc.getValueByKey("original_path"); //check the acquired image has been put into correct position. target_path = pc.getValueByKey("target_path"); int indexPath = target_path.IndexOf(";"); if (indexPath != -1) target_path = target_path.Substring(0, indexPath); //now the Processing data file not provide correct after send command bool dicomfileexist = Utility.isFileExisted(target_path); if (!dicomfileexist) { pCheckMessage.Result = TestResult.Fail; pCheckMessage.Outputs.AddParameter("Dicom File Check ERROR", "Check Command", "The acquired image not in cache place"); SaveRound(r); continue; } image_internal_id_from_mapfile = pc.getWithPathAndTypeFromMappingFile("path_mapping", "Image", "instance_internal_id"); ps_internal_id_from_mapfile = pc.getWithPathAndTypeFromMappingFile("path_mapping", "Image", "ps_internal_id"); } if (image_internal_id_from_acqResult != image_internal_id_from_mapfile) { pCheckMessage.Result = TestResult.Fail; pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "The image id from command not equals the id from getAcquisitionResult!"); SaveRound(r); continue; } if (ps_internal_id_from_acqResult != ps_internal_id_from_mapfile) { pCheckMessage.Result = TestResult.Fail; pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "The presentation id from command not equals the id from getAcquisitionResult!"); SaveRound(r); continue; } //parser the trophy xml content from command message string acq_out_xml = cn.getValueFromKey("-acq_out_xml"); string acq_out = base64tools.DecodeString4base(acq_out_xml); pCheckMessage.Outputs.AddParameter("XML From SDK", "Output acquisition SDK content", acq_out); pCheckMessage.Result = TestResult.Pass; pCheckMessage.Outputs.AddParameter("Message and Interface result", "Check Command", "All ID is matched"); CheckPoint pCheckGetImage = new CheckPoint("Check NOTIFICATION", "Acquisition complete Message"); r.CheckPoints.Add(pCheckGetImage); apps.sendGenericNotification(stopMessageType, stopMessageContent); System.Threading.Thread.Sleep(1000); //check getImageInfo int getn = rn.getNotificationNumber(); if (getn == 2) { XMLParameter getImage = new XMLParameter("image"); int indexImage = image_internal_id_from_acqResult.IndexOf(";"); if (indexImage != -1) image_internal_id_from_acqResult = image_internal_id_from_acqResult.Substring(0, indexImage); getImage.AddParameter("internal_id", image_internal_id_from_acqResult); ImageService imagesrv = new ImageService(); XMLResult getImageRsl = imagesrv.getImageInfo(getImage); //match items pCheckGetImage.Outputs.AddParameter("Get Image Info result", "Get Return XML", getImageRsl.ResultContent); int matchValueCount = 0; for (int i = 0; i < getImageRsl.DicomArrayResult.Length; i++) { if (getImageRsl.DicomArrayResult.Parameters[i].ParameterName == "internal_id" && getImageRsl.DicomArrayResult.Parameters[i].ParameterValue == image_internal_id_from_acqResult) { matchValueCount++; } if (getImageRsl.DicomArrayResult.Parameters[i].ParameterName == "patient_internal_id" && getImageRsl.DicomArrayResult.Parameters[i].ParameterValue == patient_uid) { matchValueCount++; } target_path = target_path.Replace('\\', '/'); if (getImageRsl.DicomArrayResult.Parameters[i].ParameterName == "path" && getImageRsl.DicomArrayResult.Parameters[i].ParameterValue == target_path) { matchValueCount++; } } if (matchValueCount == 3) { pCheckGetImage.Result = TestResult.Pass; pCheckGetImage.Outputs.AddParameter("Get Image Info result", "Check Return XML", "All ID is matched"); } else { pCheckGetImage.Result = TestResult.Fail; pCheckGetImage.Outputs.AddParameter("Get Image Info result", "Check Return XML", "Some ID is not matched"); } } else { pCheckGetImage.Result = TestResult.Fail; pCheckGetImage.Outputs.AddParameter("Notification not received", "Check Return", "No acquisition complete Message be received"); } } SaveRound(r); } Output(); }
//Case 1094: 1.3.7_WorkFlow_ImportDICOMImage+GetPresentationStateInfo_RadioLogInformation public void Run_PS_ImportDicom_RadioLog_Case1094() { //int runCount = this.Input.Repetition; int runCount = 0; // this is the initial run count. Use this count to repeat different test data set. foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Test round"); //Mark the check point here to indicate what's the check point here CheckPoint p1 = new CheckPoint("createPatient", "Setup environment of createPatient"); CheckPoint p2 = new CheckPoint("importObject", "Setup environment of importObject"); CheckPoint p3 = new CheckPoint("getImageInfo", "Test getImageInfo"); CheckPoint p4 = new CheckPoint("getPresentationStateInfo", "Test getPresentationStateInfo"); r.CheckPoints.Add(p1); r.CheckPoints.Add(p2); r.CheckPoints.Add(p3); r.CheckPoints.Add(p4); //create required PAS service instaces here PatientService pats = new PatientService(); ImportService ims = new ImportService(); ImageService img = new ImageService(); PresentationStateService ps = new PresentationStateService(); //create input parameters here, it may include XML path type and string type value XMLParameter pa1 = new XMLParameter("patient"); XMLParameter pa2 = new XMLParameter("importObject"); XMLParameter pa3 = new XMLParameter("image"); XMLParameter ps4 = new XMLParameter("presentationstate"); XMLParameterCollection pa4 = new XMLParameterCollection(); try { for (int i = 0; i < ids.InputParameters.Count; i++) { switch (ids.InputParameters.GetParameter(i).Step) { case "createPatient": pa1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); break; case "importObject": pa2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); break; default: Console.WriteLine("There is no valid selection when parse input parameters."); break; } } //If we need change parameter by specific logic, please put code here //Get service result //Step1 result XMLResult step1_result = pats.createPatient(pa1); //Log step1 service output if (step1_result.IsErrorOccured) { p1.Result = TestResult.Fail; p1.Outputs.AddParameter("Step 1: createPatient", "Error", step1_result.ResultContent); SaveRound(r); continue; } p1.Result = TestResult.Pass; p1.Outputs.AddParameter("Step 1: createPatient", "Success", step1_result.ResultContent); //Change input parameter according the output of Step1 pa2.AddParameter("patientInternalId", step1_result.SingleResult); //Step2 result //if objectFileFullPath is empty string, skip step2 if (pa2.GetParameterValueByName("objectFileFullPath") != null && pa2.GetParameterValueByName("objectFileFullPath") != "") { XMLResult step2_result = ims.importObject(pa2.GetParameterValueByName("patientInternalId"), "", pa2.GetParameterValueByName("objectFileFullPath"), "", false, ""); //Log step2 service output if (step2_result.IsErrorOccured) { p2.Result = TestResult.Fail; p2.Outputs.AddParameter("Step 2: importObject", "Error", step2_result.ResultContent); SaveRound(r); continue; } p2.Result = TestResult.Pass; p2.Outputs.AddParameter("Step 2: importObject", "Success", step2_result.ResultContent); //Change input parameter according the output of Step2 // if step2 is skipped, step3 input has no need parameter of internal_id for (int i = 0; i < step2_result.MultiResults.Count; i++) { if (step2_result.MultiResults[i].Name == "image") { pa3.AddParameter("internal_id", step2_result.MultiResults[i].GetParameterValueByIndex(i)); } if (step2_result.MultiResults[i].Name == "presentationstate") { pa4.Add(step2_result.MultiResults[i]); } } } //Step3 result XMLResult step3_result = img.getImageInfo(pa3); if (step3_result.IsErrorOccured) { p3.Result = TestResult.Fail; p3.Outputs.AddParameter("Step 3: getImageInfo", "The call 'getImageInfo' returns error: ", step3_result.Message); SaveRound(r); continue; } else { p3.Result = TestResult.Pass; // Assume test pass at first, check the details later to update this } //Log step3 service output int expectedParameterCount = 0; for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++) { if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo") { expectedParameterCount++; } } string dicom_info_getImageInfo = step3_result.DicomArrayResult.GetParameterValueByName("dicom_info"); for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++) { if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo") { // The dicom_info in return does not match the expected key and value if (false == dicom_info_getImageInfo.Contains("<parameter key=\"" + ids.ExpectedValues.Parameters[index].Key + "\" value=\"" + ids.ExpectedValues.Parameters[index].Value + "\" />")) { p3.Result = TestResult.Fail; p3.Outputs.AddParameter("Step 3: getImageInfo", "Error: the expect value does not match: " + ids.ExpectedValues.Parameters[index].Key + ". Actually get dicom_Info: ", dicom_info_getImageInfo); break; } } } if (p3.Result == TestResult.Pass) { p3.Outputs.AddParameter("Step 3: getImageInfo", "The dicom info all match the expected value", dicom_info_getImageInfo); } //Step4 result XMLResult step4_result = ps.getPresentationStateInfo(pa4); if (step4_result.IsErrorOccured) { p4.Result = TestResult.Fail; p4.Outputs.AddParameter("Step 4: getPresentationStateInfo", "The call 'getPresentationStateInfo' returns error: ", step4_result.Message); SaveRound(r); continue; } else { p4.Result = TestResult.Pass; } expectedParameterCount = 0; //count of expected parameters on getPresentationStateInfo for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++) { if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo") { expectedParameterCount++; } } string dicom_info_getPSInfo = step4_result.DicomArrayResult.GetParameterValueByName("dicom_info"); for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++) { if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo") { if (false == dicom_info_getPSInfo.Contains("<parameter key=\"" + ids.ExpectedValues.Parameters[index].Key + "\" value=\"" + ids.ExpectedValues.Parameters[index].Value + "\" />")) { p4.Result = TestResult.Fail; p4.Outputs.AddParameter("Step 4: getPresentationStateInfo", "Error: the expect dicom value does not match: " + ids.ExpectedValues.Parameters[index].Key + ". Actually get dicom_Info: ", dicom_info_getPSInfo); break; } } } if (p4.Result == TestResult.Pass) { p4.Outputs.AddParameter("Step 4: getPresentationStateInfo", "Success: the expect dicom value all match the expected", dicom_info_getPSInfo); } 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); } } //Save service log as xml file Output(); }
//Case 7: 1.3.7_CreatePresentationState_Normal public void Run_PS_CreatePresentationState_Normal_Case7() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Test PresentationState Service: createPresentationState"); try { #region Parameter initialize string imageInternalID = string.Empty; XMLParameter p_CreateImage = new XMLParameter("image"); XMLParameter p_CreatePresentationState = new XMLParameter("presentationstate"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "createImage") { p_CreateImage.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "createPresentationState") { p_CreatePresentationState.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } bool ep_isReturnOK = true; string ep_ReturnValue = string.Empty; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "createPresentationState") { if (ids.ExpectedValues.GetParameter(i).Key == "returnState") { if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("pass")) { ep_isReturnOK = true; } else if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("fail")) { ep_isReturnOK = false; } } else if (ids.ExpectedValues.GetParameter(i).Key == "returnMessage") { ep_ReturnValue = ids.ExpectedValues.GetParameter(i).Value; } } } #endregion ImageService imageService = new ImageService(); PresentationStateService psService = new PresentationStateService(); #region Step 1: Call ImageService.createImage to create a new image CheckPoint cp_CreateImage = new CheckPoint("Image create", "Call imageService.createImage to create a new image"); r.CheckPoints.Add(cp_CreateImage); XMLResult rt_CreateImage = imageService.createImage(p_CreateImage); if (rt_CreateImage.IsErrorOccured) { cp_CreateImage.Result = TestResult.Fail; cp_CreateImage.Outputs.AddParameter("create", "Create image returns error", rt_CreateImage.Message); SaveRound(r); continue; // There is error when create image, end current run } else { cp_CreateImage.Result = TestResult.Pass; cp_CreateImage.Outputs.AddParameter("create", "Create image returns success", rt_CreateImage.Message); imageInternalID = rt_CreateImage.SingleResult; } #endregion #region Step 2: Call PresentationStateService.CreatePresentationState to create a PS for the image CheckPoint cp_CreatePresentationState = new CheckPoint("Create PS", "Call PresentationStateService.CreatePresentationState to create a new ps"); r.CheckPoints.Add(cp_CreatePresentationState); XMLResult rt_CreatePresentationState = psService.createPresentationState(imageInternalID, p_CreatePresentationState); if (true == ep_isReturnOK) // Expect the call returns OK { if (rt_CreatePresentationState.IsErrorOccured) { cp_CreatePresentationState.Result = TestResult.Fail; cp_CreatePresentationState.Outputs.AddParameter("create", "Create PS returns error", rt_CreatePresentationState.Message); } else { cp_CreatePresentationState.Result = TestResult.Pass; cp_CreatePresentationState.Outputs.AddParameter("create", "Create PS returns success", rt_CreatePresentationState.Message); } } else // Expect the call return error { if (rt_CreatePresentationState.IsErrorOccured) // There is error { if (rt_CreatePresentationState.Message.ToLower().Contains(ep_ReturnValue.ToLower())) { cp_CreatePresentationState.Result = TestResult.Pass; cp_CreatePresentationState.Outputs.AddParameter("create", "Create PS returns error as expected", rt_CreatePresentationState.Message); } else { cp_CreatePresentationState.Result = TestResult.Fail; cp_CreatePresentationState.Outputs.AddParameter("create", "Create PS returns error message not match the expected. ", "Expect: " + ep_ReturnValue + "; Actually returns: " + rt_CreatePresentationState.Message); } } else // There is no error { cp_CreatePresentationState.Result = TestResult.Fail; cp_CreatePresentationState.Outputs.AddParameter("create", "Create PS not returns error as expected. ", "Actually returns: " + rt_CreatePresentationState.Message); } } #endregion #region Step 3: Call ImageService.deleteImage to delete the created image CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image"); r.CheckPoints.Add(cp_DeleteImage); XMLResult rt_DeleteImage = imageService.deleteImage(imageInternalID, new XMLParameter("preferences")); if (rt_DeleteImage.IsErrorOccured) { cp_DeleteImage.Result = TestResult.Fail; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message); } else { cp_DeleteImage.Result = TestResult.Pass; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message); } #endregion SaveRound(r); } catch (Exception ex) { CheckPoint cp = new CheckPoint(); r.CheckPoints.Add(cp); cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message); SaveRound(r); } } Output(); }
//Case 1043: 1.3.17_workflow_ImportCeph_GetImageInfo_RadilogIsNotSaved public void Run_WorkFlow_ImportCeph_RadioLog_Case1043() { int runCount = 0; string patientUID = string.Empty; bool isCreatePatient = false; bool isDeletePatient = true; foreach (InputDataSet ids in this.Input.DataSets) { isCreatePatient = false; runCount++; Round r = this.NewRound(runCount.ToString(), "Import image"); PatientService patientSvc = new PatientService(); ImportService importSvc = new ImportService(); ImageService imageSvc = new ImageService(); string radioLogBeforeImport = string.Empty; string radioLogAfterImport = string.Empty; string imageID = null; XMLParameter pa = new XMLParameter("patient"); XMLParameter ia = new XMLParameter("import"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "create") { pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); isCreatePatient = true; } if (ids.InputParameters.GetParameter(i).Step == "import") { ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } XMLParameter epGetImagInfo = new XMLParameter(); for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo") { epGetImagInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } try { #region Step1: Create Image if (isCreatePatient) { CheckPoint pCreate = new CheckPoint("Create Patient", "Test create"); r.CheckPoints.Add(pCreate); XMLResult rtCreatePatient = patientSvc.createPatient(pa); if (!rtCreatePatient.IsErrorOccured) { patientUID = rtCreatePatient.SingleResult; pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID); pCreate.Result = TestResult.Pass; } } #endregion #region Step2: Get patient radio log info before import CheckPoint cpGetPatientBeforeImport = new CheckPoint("GetPatient", "Get Patient Info before import image"); r.CheckPoints.Add(cpGetPatientBeforeImport); XMLResult rtGetPatientBeforeImport = patientSvc.getPatient(patientUID); if (rtGetPatientBeforeImport.IsErrorOccured) { cpGetPatientBeforeImport.Result = TestResult.Fail; cpGetPatientBeforeImport.Outputs.AddParameter("Get Patient Info before import image returns error", "GetPatient", rtGetPatientBeforeImport.ResultContent); } else { cpGetPatientBeforeImport.Result = TestResult.Pass; cpGetPatientBeforeImport.Outputs.AddParameter("Get Patient Info before import image returns ok", "GetPatient", rtGetPatientBeforeImport.ResultContent); radioLogBeforeImport = rtGetPatientBeforeImport.MultiResults[0].GetParameterValueByName("cumulative_dose"); //get the cumulative_dose info } #endregion #region Step3: Import Image CheckPoint pImport = new CheckPoint("Import Image", "Test import"); r.CheckPoints.Add(pImport); string filePath = string.Empty; string archivePath = string.Empty; bool move = false; for (int c = 0; c < ia.Length; c++) { if (ia.GetParameterName(c) == "path") { filePath = ia.GetParameterValue(c); } else if (ia.GetParameterName(c) == "archivePath") { archivePath = ia.GetParameterValue(c); } else if (ia.GetParameterName(c) == "move") { if (ia.GetParameterValue(c) == "true") { move = true; } } } XMLResult rtlImport = importSvc.importObject(patientUID, "", filePath, archivePath, move, "false"); //import return sample: // <trophy type="result" version="1.0"> // <status code="0" message="ok" /> // <image><parameter key="internal_id" value="2bfb416b-037e-41e7-aaef-8d2bd08b1ae7" /></image> // <presentationstate><parameter key="internal_id" value="75675345-a164-4088-b6d3-1b2ae86b703b" /></presentationstate> // </trophy> if (rtlImport.IsErrorOccured) { pImport.Result = TestResult.Fail; pImport.Outputs.AddParameter("Import image fail", "Import", rtlImport.Message); pImport.Outputs.AddParameter("Import image returns error code", "Import", rtlImport.Code.ToString()); } else { // Check the return contiains image id and ps id imageID = rtlImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id if (imageID == null || imageID == string.Empty) { pImport.Result = TestResult.Fail; pImport.Outputs.AddParameter("Import image returns wrong image internal id", "Import", rtlImport.ResultContent); } string psID = null; psID = rtlImport.MultiResults[1].GetParameterValueByName("internal_id"); // ps internal_id if (psID == null || psID == string.Empty) { pImport.Result = TestResult.Fail; pImport.Outputs.AddParameter("import image returns wrong ps internal id", "Import", rtlImport.ResultContent); } else { pImport.Result = TestResult.Pass; pImport.Outputs.AddParameter("import image returns OK", "Import", rtlImport.ResultContent); } } #endregion #region Step4: Call GetImageInfo to check the radio log info CheckPoint cpGetImageInfo = new CheckPoint("GetImageInfo", "Get the image info of the imported image"); r.CheckPoints.Add(cpGetImageInfo); XMLParameter pGetImageInfo = new XMLParameter("image"); pGetImageInfo.AddParameter("internal_id", imageID); XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfo); if (rtGetImageInfo.IsErrorOccured) { cpGetImageInfo.Result = TestResult.Fail; cpGetImageInfo.Outputs.AddParameter("Get the image info of the imported image return error", "GetImageInfo", rtGetImageInfo.ResultContent); } else { cpGetImageInfo.Outputs.AddParameter("Get Image Info return success", "getImageInfo", rtGetImageInfo.Message); //Check the return info contain the expected key and value: <parameter key="XXX" value="XXX" /> foreach (XMLParameterNode node in epGetImagInfo.Parameters) { if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\"")) { cpGetImageInfo.Result = TestResult.Fail; cpGetImageInfo.Outputs.AddParameter("Get Image Info returns wrong key-value info for: " + node.ParameterName, "GetImageInfo", rtGetImageInfo.ResultContent); continue; } else { cpGetImageInfo.Outputs.AddParameter("Get Image Info returns correct key-value info for: " + node.ParameterName, "GetImageInfo", "ok"); } } if (cpGetImageInfo.Result != TestResult.Fail) { cpGetImageInfo.Result = TestResult.Pass; cpGetImageInfo.Outputs.AddParameter("Get Image Info return all correct info", "GetImageInfo", rtGetImageInfo.ResultContent); } } #endregion #region Step5: Get patient radio log info after import CheckPoint cpGetPatientAfterImport = new CheckPoint("GetPatient", "Get Patient Info after import image"); r.CheckPoints.Add(cpGetPatientAfterImport); XMLResult rtGetPatientAfterImport = patientSvc.getPatient(patientUID); if (rtGetPatientAfterImport.IsErrorOccured) { cpGetPatientAfterImport.Result = TestResult.Fail; cpGetPatientAfterImport.Outputs.AddParameter("Get Patient Info after import image returns error", "GetPatient", rtGetPatientAfterImport.ResultContent); } else { cpGetPatientAfterImport.Result = TestResult.Pass; cpGetPatientAfterImport.Outputs.AddParameter("Get Patient Info after import image returns ok", "GetPatient", rtGetPatientAfterImport.ResultContent); radioLogAfterImport = rtGetPatientAfterImport.MultiResults[0].GetParameterValueByName("cumulative_dose"); //get the cumulative_dose info } #endregion #region Step6: Check the patient radio log info not changes after import image CheckPoint cpPatientRadioLogInfo = new CheckPoint("Patient Radiolog Info", "Check patient radio log info not changes aftert import image"); r.CheckPoints.Add(cpPatientRadioLogInfo); if (radioLogAfterImport == radioLogBeforeImport) { cpPatientRadioLogInfo.Result = TestResult.Pass; cpPatientRadioLogInfo.Outputs.AddParameter("Patient radio log info not changes aftert import image", "Patient Radiolog Info", "Before import value is: " + radioLogBeforeImport + ". After import value is: " + radioLogAfterImport); } else { cpPatientRadioLogInfo.Result = TestResult.Fail; cpPatientRadioLogInfo.Outputs.AddParameter("Patient radio log info changes aftert import image", "Patient Radiolog Info", "Before import value is: " + radioLogBeforeImport + ". After import value is: " + radioLogAfterImport); } #endregion #region Step7: Delete Patient if (isDeletePatient) { CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient"); r.CheckPoints.Add(cpDelete); XMLResult rltDelete = patientSvc.deletePatient(patientUID); if (rltDelete.IsErrorOccured) { cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message); cpDelete.Result = TestResult.Fail; } else { cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.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 976: 1.3.1_GetPatient_N2_getCumulativeDose public void Run_Patient_GetPatient_CumulativeDose_Case976() { int runCount = 0; string patientUID = string.Empty; string dose_value = string.Empty; bool isCreatePatient = false; foreach (InputDataSet ids in this.Input.DataSets) { isCreatePatient = false; runCount++; Round r = this.NewRound(runCount.ToString(), "Cumulative Dose"); PatientService ps = new PatientService(); ImageService igs = new ImageService(); XMLParameter cpatientData = new XMLParameter("patient"); XMLParameter imageData = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "create") { cpatientData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); isCreatePatient = true; } if (ids.InputParameters.GetParameter(i).Step == "Image") { imageData.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); if (ids.InputParameters.GetParameter(i).Key == "area_dose_product") dose_value = ids.InputParameters.GetParameter(i).Value; } } if (isCreatePatient) { CheckPoint pCreate = new CheckPoint("Create Patient", "Test create"); r.CheckPoints.Add(pCreate); XMLResult rslCreate = ps.createPatient(cpatientData); if (!rslCreate.IsErrorOccured) { patientUID = rslCreate.SingleResult; pCreate.Result = TestResult.Pass; pCreate.Outputs.AddParameter("create", "Create patient UID", patientUID); } else { pCreate.Result = TestResult.Fail; pCreate.Outputs.AddParameter("create", "Create patient ERR", rslCreate.Message); goto CLEANUP; } } if (patientUID != null) { imageData.AddParameter("patient_internal_id", patientUID); CheckPoint imageSet = new CheckPoint("Create image", "Create image"); r.CheckPoints.Add(imageSet); XMLResult rslCreateImage = igs.createImage(imageData); if (rslCreateImage.IsErrorOccured) { imageSet.Outputs.AddParameter("Create", "Create Image Fail", rslCreateImage.Message); imageSet.Result = TestResult.Fail; } else { imageSet.Outputs.AddParameter("Create", "Create Image UID", rslCreateImage.SingleResult); imageSet.Result = TestResult.Pass; CheckPoint pGet = new CheckPoint("Get Patient", "Get Cumulative Dose"); r.CheckPoints.Add(pGet); XMLResult rslGet = ps.getPatient(patientUID); if (!rslGet.IsErrorOccured && rslGet.Code == 0) { for (int j = 0; j < rslGet.ArrayResult.Parameters.Count; j++) { if (rslGet.ArrayResult.Parameters[j].ParameterName == "cumulative_dose") { if (double.Parse(rslGet.ArrayResult.Parameters[j].ParameterValue) == double.Parse(dose_value)) { pGet.Outputs.AddParameter("Get", "Get patient OK", rslGet.ResultContent); pGet.Result = TestResult.Pass; } else { pGet.Outputs.AddParameter("Get", "Get wrong dose_value", "Expect: " + dose_value + "; actually get: " + rslGet.ArrayResult.Parameters[j].ParameterValue); pGet.Result = TestResult.Fail; goto CLEANUP; } } } } else { pGet.Outputs.AddParameter("Get", "Get patient Error", rslGet.ResultContent); pGet.Result = TestResult.Fail; } } } CLEANUP: SaveRound(r); if (isCreatePatient && !string.IsNullOrEmpty(patientUID)) { ps.deletePatient(patientUID); } } Output(); }
//Case 45: 1.3.6_GetImageDescription_Normal public void Run_Image_GetImageDescription_Normal_Case45() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { string imageID = null; // Input parameter XMLParameter pGetImageDescription = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "getImageDescription") { if (ids.InputParameters.GetParameter(i).Key == "internal_id") { imageID = ids.InputParameters.GetParameter(i).Value; } } } // Output value XMLParameter epGetImageDescription_image = new XMLParameter("image"); XMLParameter epGetImageDescription_series = new XMLParameter("series"); for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_image") { if (ids.ExpectedValues.GetParameter(i).Key == "path") { string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value; epGetImageDescription_image.AddParameter("path", path); } else { epGetImageDescription_image.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_series") { epGetImageDescription_series.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } #region Step 1: Call ImageService.getImageDescription to get the image description CheckPoint cpGetImageDescription = new CheckPoint("getImageDescription", "Call ImageService.getImageDescription to get the image description"); r.CheckPoints.Add(cpGetImageDescription); ImageService imageService = new ImageService(); XMLResult rtGetImageDescription = imageService.getImageDescription(imageID); if (rtGetImageDescription.IsErrorOccured) { cpGetImageDescription.Result = TestResult.Fail; cpGetImageDescription.Outputs.AddParameter("getImageDescription", "Call ImageService.getImageDescription to get the image description", rtGetImageDescription.Message); SaveRound(r); break; // There is error, end test case } else { cpGetImageDescription.Result = TestResult.Pass; cpGetImageDescription.Outputs.AddParameter("getImageDescription", "Call ImageService.getImageDescription to get the image description", rtGetImageDescription.Message); } #endregion #region Step 2: Check the values in ImageService.getImageDescription return are correct bool isValueEqual = true; bool isKeyShow = true; #region Check image info CheckPoint cpImageInfo = new CheckPoint("Image Info", "Check the values in ImageService.getImageDescription return"); r.CheckPoints.Add(cpImageInfo); foreach (XMLParameterNode psNode in epGetImageDescription_image.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < rtGetImageDescription.MultiResults[0].Parameters.Count; i++) { if (psNode.ParameterName == rtGetImageDescription.MultiResults[0].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, rtGetImageDescription.MultiResults[0].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { cpImageInfo.Result = TestResult.Fail; if (isKeyShow) { cpImageInfo.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageDescription return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rtGetImageDescription.MultiResults[0].Parameters[i].ParameterValue); } else { cpImageInfo.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageDescription return", "The return value in getImageDescription does not contain the node: " + psNode.ParameterName); } break; // Break current foreach loop, not compare the follwing nodes } } if (isValueEqual) // Need this to judge it comes from break or normal flow which has complete all node comparation { cpImageInfo.Result = TestResult.Pass; cpImageInfo.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageDescription return", "The return values in getImageDescription all match the expected"); } #endregion #region Check series info CheckPoint cpSeriesInfo = new CheckPoint("Series Info", "Check the values in ImageService.getImageDescription return"); r.CheckPoints.Add(cpSeriesInfo); foreach (XMLParameterNode psNode in epGetImageDescription_series.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < rtGetImageDescription.MultiResults[1].Parameters.Count; i++) { if (psNode.ParameterName == rtGetImageDescription.MultiResults[1].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, rtGetImageDescription.MultiResults[1].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { cpSeriesInfo.Result = TestResult.Fail; if (isKeyShow) { cpSeriesInfo.Outputs.AddParameter("Series Info", "Check the values in ImageService.getImageDescription return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rtGetImageDescription.MultiResults[1].Parameters[i].ParameterValue); } else { cpSeriesInfo.Outputs.AddParameter("Series Info", "Check the values in ImageService.getImageDescription return", "The return value in getImageDescription does not contain the node: " + psNode.ParameterName); } break; // Break current foreach loop, not compare the follwing nodes } } if (isValueEqual) { cpSeriesInfo.Result = TestResult.Pass; cpSeriesInfo.Outputs.AddParameter("Series Info", "Check the values in ImageService.getImageDescription return", "The return values in getImageDescription all match the expected"); } #endregion #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 159: 1.3.8_1.3.8_DeleteFMS_Normal public void Run_FMS_DeleteFMS_Normal_Case159() { int runCount = 0; string acquireType = string.Empty; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Acquisition"); AcquisitionService acqs = new AcquisitionService(); FMSService fmss = new FMSService(); ImageService igs = new ImageService(); PresentationStateService pss = new PresentationStateService(); XMLParameter acq = new XMLParameter("acq_info"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "acquire") { acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "acquireType") { acquireType = ids.InputParameters.GetParameter(i).Key; } } CheckPoint pAcquire = new CheckPoint("Acquire Image", "Acquisition FMS"); r.CheckPoints.Add(pAcquire); System.Diagnostics.Debug.Print("Acquire start"); XMLResult rslAcqRVG = acqs.startAcquisition(acq); System.Threading.Thread.Sleep(3000); switch (acquireType) { case "FMS": System.Diagnostics.Debug.Print("FMS Acquire"); Utility.AcqFMS(15, 300); //can not set too long, otherwise there may be overtaken images break; default: System.Diagnostics.Debug.Print("NOT FMS/PANO/CEPH/CR Acquire"); break; } if (rslAcqRVG.IsErrorOccured) { System.Diagnostics.Debug.Print("Acquire fail:"); pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcqRVG.Message); } else { pAcquire.Outputs.AddParameter("Acquire session ID", "startAcquisition", rslAcqRVG.SingleResult); int DORVGcount = 0; XMLResult getAcqRVG = new XMLResult(); do { System.Threading.Thread.Sleep(3000); System.Diagnostics.Debug.Print("get acquire in do"); DORVGcount++; getAcqRVG = acqs.getAcquisitionResult(rslAcqRVG.SingleResult); if (!getAcqRVG.IsErrorOccured) { ParseXMLContent parser = new ParseXMLContent(getAcqRVG.ResultContent); // To parse the return XML string fmsID = parser.getStringWithPathAndType("trophy/object_info", "fms", "value"); string[] fmsIDs = fmsID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int fmsCount = fmsIDs.Length; string imageID = parser.getStringWithPathAndType("trophy/object_info", "image", "value"); string[] imageIDs = imageID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int imageCount = imageIDs.Length; string psID = parser.getStringWithPathAndType("trophy/object_info", "presentation_state", "value"); string[] psIDs = psID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int psCount = psIDs.Length; if (fmsCount == 1 && imageCount >= 1 && psCount >= 1 && imageCount == psCount) { string FMSInternalID = fmsIDs[0]; XMLResult delFmsRls = fmss.deleteFMS("true", FMSInternalID); if (delFmsRls.IsErrorOccured) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Delete FMS Result", "Acquisition", delFmsRls.ResultContent); pAcquire.Outputs.AddParameter("Delete FMS", "Acquisition", "Delete FMS Error"); break; } pAcquire.Outputs.AddParameter("Delete FMS Result", "Acquisition", delFmsRls.ResultContent); XMLResult getFmsRls = fmss.getFMSDescription(FMSInternalID); if (!getFmsRls.IsErrorOccured) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Get FMS", "Acquisition", getFmsRls.ResultContent); pAcquire.Outputs.AddParameter("Get FMS", "Acquisition", "FMS does not delete"); break; } pAcquire.Outputs.AddParameter("Get FMS", "Acquisition", getFmsRls.ResultContent); bool isImageExisted = false; for (int i = 1; i <= imageIDs.Length; i++) { XMLResult getImageRls = igs.getImageDescription(imageIDs[i - 1]); if (!getImageRls.IsErrorOccured) { isImageExisted = true; break; } pAcquire.Outputs.AddParameter("Get FMS Images: " + i, "Acquisition", getImageRls.ResultContent); } if (isImageExisted) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Get FMS Images", "Acquisition", "Images is not deleted from FMS"); break; } pAcquire.Result = TestResult.Pass; pAcquire.Outputs.AddParameter("Delete FMS and images", "Acquisition", "Fms and imahes have been deleted"); } else { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("getAcquisitionResult", "Acquisition", "No Image or PS id return"); } break; } if (getAcqRVG.IsErrorOccured && getAcqRVG.Code != 499) continue; if (getAcqRVG.Code != 0 && getAcqRVG.Code != 499) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", getAcqRVG.Message); } System.Diagnostics.Debug.Print("get acquireResult:" + DORVGcount); if (DORVGcount > 60) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", "Acquire great with 3 minutes, timeout!"); break; } } while (true); } SaveRound(r); } Output(); }
//Case 99: 1.3.6_CreateImage_Exception public void Run_Image_CreateImage_Exception_Case99() { int runCount = 0; string patientUID = string.Empty; bool isCreatePatient = false; bool isDeletePatient = false; foreach (InputDataSet ids in this.Input.DataSets) { isCreatePatient = false; isDeletePatient = false; runCount++; Round r = this.NewRound(runCount.ToString(), "Create image"); PatientService patientSvc = new PatientService(); ImageService imageSvc = new ImageService(); XMLParameter pCreatePatient = new XMLParameter("patient"); XMLParameter pCreateImage = new XMLParameter("image"); 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); isCreatePatient = true; } if (ids.InputParameters.GetParameter(i).Step == "createImage") { pCreateImage.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "deletePatient") { isDeletePatient = ids.InputParameters.GetParameter(i).Value.ToLower().Equals("true"); } } string epErrorCode = string.Empty; string epErrorMessage = string.Empty; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "createImage") { if (ids.ExpectedValues.GetParameter(i).Key == "error_code") { epErrorCode = ids.ExpectedValues.GetParameter(i).Value; } else if (ids.ExpectedValues.GetParameter(i).Key == "error_message") { epErrorMessage = ids.ExpectedValues.GetParameter(i).Value; } } } try { #region Create Patient if (isCreatePatient) { CheckPoint cpCreatePatient = new CheckPoint("Create Patient", "Test create patient"); r.CheckPoints.Add(cpCreatePatient); XMLResult rtCreatePatient = patientSvc.createPatient(pCreatePatient); if (rtCreatePatient.IsErrorOccured) { cpCreatePatient.Result = TestResult.Fail; cpCreatePatient.Outputs.AddParameter("create patient returns error", "Create Patient", rtCreatePatient.ResultContent); SaveRound(r); break; } else { patientUID = rtCreatePatient.SingleResult; cpCreatePatient.Result = TestResult.Pass; cpCreatePatient.Outputs.AddParameter("create patient returns success", "Create Patient", rtCreatePatient.ResultContent); } } #endregion #region Create Image CheckPoint cpCreateImage = new CheckPoint("Create Image", "Test create image"); r.CheckPoints.Add(cpCreateImage); if (patientUID != null) { pCreateImage.AddParameter("patient_internal_id", patientUID); XMLResult rtCreateImage = imageSvc.createImage(pCreateImage); if (rtCreateImage.IsErrorOccured) { if (rtCreateImage.Code.ToString().Equals(epErrorCode) && rtCreateImage.Message.Contains(epErrorMessage)) { cpCreateImage.Result = TestResult.Pass; cpCreateImage.Outputs.AddParameter("Create image returns correct error message as expected", "Create Image", rtCreateImage.ResultContent); } else { cpCreateImage.Result = TestResult.Fail; cpCreateImage.Outputs.AddParameter("Create image doesn't return correct error info as expected", "Create Image", rtCreateImage.ResultContent); } } else { cpCreateImage.Result = TestResult.Fail; cpCreateImage.Outputs.AddParameter("Create image doesn't return error as expected", "Create Image", rtCreateImage.ResultContent); } } #endregion #region Delete patient if (isDeletePatient) { CheckPoint cpDeletePatient = new CheckPoint("DeletePatient", "Delete the created patient"); r.CheckPoints.Add(cpDeletePatient); XMLResult rtDeletePatient = patientSvc.deletePatient(patientUID); if (rtDeletePatient.IsErrorOccured) { cpDeletePatient.Result = TestResult.Fail; cpDeletePatient.Outputs.AddParameter("delete patient returns error", "Delete Patient", rtDeletePatient.ResultContent); SaveRound(r); break; } else { cpDeletePatient.Result = TestResult.Pass; cpDeletePatient.Outputs.AddParameter("delete patient returns success", "Delete Patient", rtDeletePatient.ResultContent); } } #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 1624: 1.3.6_WorkFlow_N05_Import DICOM Image_Check DICOM Info public void Run_Image_Import_GetInfo_Case1624() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { // Input parameter string patientID = null; string objectFileFullPath = null; string imageID = null; for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "import") { if (ids.InputParameters.GetParameter(i).Key == "patientID") { patientID = ids.InputParameters.GetParameter(i).Value; } else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath") { objectFileFullPath = ids.InputParameters.GetParameter(i).Value; } } } // Output value XMLParameter getImageInfoReturnValue = new XMLParameter("image"); for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo") { if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr { string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value; getImageInfoReturnValue.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path); } else { getImageInfoReturnValue.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } } #region Step: mport the image ImportService importSvc = new ImportService(); XMLResult rtImport = importSvc.CallImportAndCheck(r, patientID, objectFileFullPath, null); if (rtImport.IsErrorOccured) { continue; } else { imageID = rtImport.SingleResult; } #endregion #region Step 1: Call ImageService.getImageInfo to get the image info CheckPoint pGetImageInfo = new CheckPoint("getImageInfo", "Call ImageService.getImageInfo to get the image info"); r.CheckPoints.Add(pGetImageInfo); ImageService imageService = new ImageService(); XMLParameter getImageInfoParam = new XMLParameter("image"); getImageInfoParam.AddParameter("internal_id", imageID); XMLResult getImageInfoResult = imageService.getImageInfo(getImageInfoParam); if (getImageInfoResult.IsErrorOccured) { pGetImageInfo.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info returns error."); pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message); SaveRound(r); break; // There is error, end test case } else { pGetImageInfo.Result = TestResult.Pass; System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info succeeds."); pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message); } #endregion #region Step 2: Check the values in ImageService.getImageInfo return are correct CheckPoint pImageInfo = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return"); r.CheckPoints.Add(pImageInfo); string dicom_info = null; for (int i = 0; i < getImageInfoResult.DicomArrayResult.Parameters.Count; i++) { if (getImageInfoResult.DicomArrayResult.Parameters[i].ParameterName == "dicom_info") { dicom_info = getImageInfoResult.DicomArrayResult.Parameters[i].ParameterValue; break; // End current for loop to search node } } foreach (XMLParameterNode psNode in getImageInfoReturnValue.Parameters) { if (!dicom_info.Contains("<parameter key=\"" + psNode.ParameterName + "\" value=\"" + psNode.ParameterValue + "\" />")) //example: <parameter key="dcm_modality" value="IO" /> { pImageInfo.Result = TestResult.Fail; pImageInfo.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + dicom_info); } } if (pImageInfo.Result != TestResult.Fail) { pImageInfo.Result = TestResult.Pass; pImageInfo.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return", "The return values in getImageInfo all match the expected. Get:" + getImageInfoResult.ResultContent); } #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 1172: 1.3.6_GetImageInfo_N03_4 valid ID public void Run_Image_GetInfo_4ID_Case1172() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { // Input parameter XMLParameter getImageInfoParam = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { getImageInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } // Output value XMLParameter getImageInfoReturn_1 = new XMLParameter("image"); XMLParameter getImageInfoReturn_2 = new XMLParameter("image"); XMLParameter getImageInfoReturn_3 = new XMLParameter("image"); XMLParameter getImageInfoReturn_4 = new XMLParameter("image"); for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_1") { if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr { string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value; getImageInfoReturn_1.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path); } else { getImageInfoReturn_1.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_2") { if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr { string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value; getImageInfoReturn_2.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path); } else { getImageInfoReturn_2.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_3") { if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr { string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value; getImageInfoReturn_3.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path); } else { getImageInfoReturn_3.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_4") { if (ids.ExpectedValues.GetParameter(i).Key == "path") // to handle different path, such as in different OS or user changes the install dr { string path = Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory") + ids.ExpectedValues.GetParameter(i).Value; getImageInfoReturn_4.AddParameter(ids.ExpectedValues.GetParameter(i).Key, path); } else { getImageInfoReturn_4.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } } #region Step 1: Call ImageService.getImageInfo to get the image info CheckPoint pGetImageInfo = new CheckPoint("getImageInfo", "Call ImageService.getImageInfo to get the image info"); r.CheckPoints.Add(pGetImageInfo); ImageService imageService = new ImageService(); XMLResult getImageInfoResult = imageService.getImageInfo(getImageInfoParam); if (getImageInfoResult.IsErrorOccured) { pGetImageInfo.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info returns error."); pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message); SaveRound(r); break; // There is error, end test case } else { pGetImageInfo.Result = TestResult.Pass; System.Diagnostics.Debug.Print("Call ImageService.getImageInfo to get the image info succeeds."); pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo to get the image info", getImageInfoResult.Message); } #endregion bool isValueEqual = false; bool isKeyShow = false; #region Step 2: Check the values in ImageService.getImageInfo return for the 1st image are correct CheckPoint pImageInfo_1 = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return for the 1st image"); r.CheckPoints.Add(pImageInfo_1); // Check the return for the 1st image foreach (XMLParameterNode psNode in getImageInfoReturn_1.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < getImageInfoResult.MultiResults[0].Parameters.Count; i++) { if (psNode.ParameterName == getImageInfoResult.MultiResults[0].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, getImageInfoResult.MultiResults[0].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { pImageInfo_1.Result = TestResult.Fail; if (isKeyShow) { System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected."); pImageInfo_1.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + getImageInfoResult.MultiResults[0].Parameters[i].ParameterValue); } else { System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName); pImageInfo_1.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName); } break; // End current foreach loop, not compare the following nodes } } if (isValueEqual) { pImageInfo_1.Result = TestResult.Pass; System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected."); pImageInfo_1.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 1st image", "The return values in getImageInfo all match the expected"); } #endregion #region Step 3: Check the values in ImageService.getImageInfo return for the 2nd image are correct CheckPoint pImageInfo_2 = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return for the 2nd image"); r.CheckPoints.Add(pImageInfo_2); foreach (XMLParameterNode psNode in getImageInfoReturn_2.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < getImageInfoResult.MultiResults[1].Parameters.Count; i++) { if (psNode.ParameterName == getImageInfoResult.MultiResults[1].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, getImageInfoResult.MultiResults[1].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { pImageInfo_2.Result = TestResult.Fail; if (isKeyShow) { System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected."); pImageInfo_2.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 2nd image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + getImageInfoResult.MultiResults[1].Parameters[i].ParameterValue); } else { System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName); pImageInfo_2.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 2nd image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName); } break; // End current foreach loop, not compare the following nodes } } if (isValueEqual) { pImageInfo_2.Result = TestResult.Pass; System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected."); pImageInfo_2.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 2nd image", "The return values in getImageInfo all match the expected"); } #endregion #region Step 4: Check the values in ImageService.getImageInfo return for the 3rd image are correct CheckPoint pImageInfo_3 = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return for the 3rd image"); r.CheckPoints.Add(pImageInfo_3); foreach (XMLParameterNode psNode in getImageInfoReturn_3.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < getImageInfoResult.MultiResults[2].Parameters.Count; i++) { if (psNode.ParameterName == getImageInfoResult.MultiResults[2].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, getImageInfoResult.MultiResults[2].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { pImageInfo_3.Result = TestResult.Fail; if (isKeyShow) { System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected."); pImageInfo_3.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 3rd image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + getImageInfoResult.MultiResults[2].Parameters[i].ParameterValue); } else { System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName); pImageInfo_3.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 3rd image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName); } break; // End current foreach loop, not compare the following nodes } } if (isValueEqual) { pImageInfo_3.Result = TestResult.Pass; System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected."); pImageInfo_3.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 3rd image", "The return values in getImageInfo all match the expected"); } #endregion #region Step 5: Check the values in ImageService.getImageInfo return for the 4th image are correct CheckPoint pImageInfo_4 = new CheckPoint("ImageInfo", "Check the values in ImageService.getImageInfo return for the 4th image"); r.CheckPoints.Add(pImageInfo_4); foreach (XMLParameterNode psNode in getImageInfoReturn_4.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < getImageInfoResult.MultiResults[3].Parameters.Count; i++) { if (psNode.ParameterName == getImageInfoResult.MultiResults[3].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, getImageInfoResult.MultiResults[3].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { pImageInfo_4.Result = TestResult.Fail; if (isKeyShow) { System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected."); pImageInfo_4.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 4th image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + getImageInfoResult.MultiResults[3].Parameters[i].ParameterValue); } else { System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName); pImageInfo_4.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 4th image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName); } break; // End current foreach loop, not compare the following nodes } } if (isValueEqual) { pImageInfo_4.Result = TestResult.Pass; System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected."); pImageInfo_4.Outputs.AddParameter("ImageInfo", "Check the values in ImageService.getImageInfo return for the 4th image", "The return values in getImageInfo all match the expected"); } #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 44: 1.3.6_CreateImage_Normal public void Run_Image_CreateImage_Normal_Case44() { int runCount = 0; string patientUID = null; bool isCreatePatient = false; foreach (InputDataSet ids in this.Input.DataSets) { isCreatePatient = false; runCount++; Round r = this.NewRound(runCount.ToString(), "Create image"); PatientService ps = new PatientService(); ImageService ims = new ImageService(); XMLParameter pa = new XMLParameter("patient"); XMLParameter ia = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "create") { pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); isCreatePatient = true; } if (ids.InputParameters.GetParameter(i).Step == "image") { ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } if (isCreatePatient) { CheckPoint pCreate = new CheckPoint("Create patient", "Test create"); r.CheckPoints.Add(pCreate); XMLResult result = ps.createPatient(pa); if (!result.IsErrorOccured) { patientUID = result.SingleResult; pCreate.Outputs.AddParameter("create", "Create patient UID", patientUID); pCreate.Result = TestResult.Pass; } else { pCreate.Outputs.AddParameter("create", "Create patient returns error: ", result.ResultContent); pCreate.Result = TestResult.Fail; goto CLEANUP; } } CheckPoint pImage = new CheckPoint("Image create", "Test image"); r.CheckPoints.Add(pImage); if (patientUID != null) { ia.AddParameter("patient_internal_id", patientUID); XMLResult imageRsl = ims.createImage(ia); if (imageRsl.IsErrorOccured) { pImage.Result = TestResult.Fail; pImage.Outputs.AddParameter("create", "Create image error", imageRsl.Message); } else { pImage.Result = TestResult.Pass; pImage.Outputs.AddParameter("create", "Create image Id", imageRsl.SingleResult); } } CLEANUP: if (isCreatePatient && !string.IsNullOrEmpty(patientUID)) { ps.deletePatient(patientUID); } SaveRound(r); } Output(); }
// Case 721: 1.3.10_ImportImage_N02_Archived image public void Run_Import_ArchivedImage_Case721() { int runCount = 0; string patientUID = string.Empty; bool isCreatePatient = false; bool isDeletePatient = true; foreach (InputDataSet ids in this.Input.DataSets) { isCreatePatient = false; runCount++; Round r = this.NewRound(runCount.ToString(), "Import image"); ImportService ims = new ImportService(); XMLParameter pa = new XMLParameter("patient"); XMLParameter ia = new XMLParameter("import"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "create") { pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); isCreatePatient = true; } if (ids.InputParameters.GetParameter(i).Step == "import") { ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } XMLParameter epGetImagInfo = new XMLParameter(); XMLParameter epGetImageDescription = new XMLParameter(); for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo") { epGetImagInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription") { epGetImageDescription.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } try { PatientService patientSvc = new PatientService(); if (isCreatePatient) { CheckPoint pCreate = new CheckPoint("Create Patient", "Test create"); r.CheckPoints.Add(pCreate); XMLResult result = patientSvc.createPatient(pa); if (!result.IsErrorOccured) { patientUID = result.SingleResult; pCreate.Result = TestResult.Pass; pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID); } else { pCreate.Result = TestResult.Fail; pCreate.Outputs.AddParameter("Create patient returns error", "Create Patient", result.ResultContent); } } CheckPoint pImport = new CheckPoint("Import Image", "Test import"); r.CheckPoints.Add(pImport); string filePath = string.Empty; string archivePath = string.Empty; bool move = false; for (int c = 0; c < ia.Length; c++) { if (ia.GetParameterName(c) == "path") filePath = ia.GetParameterValue(c); if (ia.GetParameterName(c) == "archivePath") archivePath = ia.GetParameterValue(c); if (ia.GetParameterName(c) == "move") { if (ia.GetParameterValue(c) == "true") move = true; } } XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false"); //import return sample: // <trophy type="result" version="1.0"> // <status code="0" message="ok" /> // <image><parameter key="internal_id" value="2bfb416b-037e-41e7-aaef-8d2bd08b1ae7" /></image> // <presentationstate><parameter key="internal_id" value="75675345-a164-4088-b6d3-1b2ae86b703b" /></presentationstate> // </trophy> if (rslImport.IsErrorOccured) { pImport.Result = TestResult.Fail; pImport.Outputs.AddParameter("Import image fail", "Import", rslImport.Message); pImport.Outputs.AddParameter("Import image returns error code", "Import", rslImport.Code.ToString()); } else { // Check the return contiains image id and ps id string imageID = null; imageID = rslImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id if (imageID == null || imageID == string.Empty) { pImport.Result = TestResult.Fail; pImport.Outputs.AddParameter("Import image returns wrong image internal id", "Import", rslImport.ResultContent); } string psID = null; psID = rslImport.MultiResults[1].GetParameterValueByName("internal_id"); // ps internal_id if (psID == null || psID == string.Empty) { pImport.Result = TestResult.Fail; pImport.Outputs.AddParameter("import image returns wrong ps internal id", "Import", rslImport.ResultContent); } else { pImport.Result = TestResult.Pass; pImport.Outputs.AddParameter("import image returns OK", "Import", rslImport.ResultContent); } #region Call getImageInfo to check expected key and value ImageService imageSvc = new ImageService(); XMLParameter pGetImageInfo = new XMLParameter("image"); pGetImageInfo.AddParameter("internal_id", imageID); CheckPoint cpGetImageInfo = new CheckPoint("GetImageInfo", "Call GetImageInfo to check the dcm_anatomic_region value"); r.CheckPoints.Add(cpGetImageInfo); XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfo); if (rtGetImageInfo.IsErrorOccured) { cpGetImageInfo.Result = TestResult.Fail; cpGetImageInfo.Outputs.AddParameter("Get Image Info return error", "getImageInfo", rtGetImageInfo.ResultContent); } else { cpGetImageInfo.Outputs.AddParameter("Get Image Info return success", "getImageInfo", rtGetImageInfo.Message); //Check the return info contain the expected key and value: parameter key="XXX" value="XXX" foreach (XMLParameterNode node in epGetImagInfo.Parameters) { if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\"")) { cpGetImageInfo.Result = TestResult.Fail; cpGetImageInfo.Outputs.AddParameter("Get Image Info returns wrong key-value info for: " + node.ParameterName, "GetImageInfo", rtGetImageInfo.ResultContent); continue; } else { cpGetImageInfo.Outputs.AddParameter("Get Image Info returns correct key-value info for: " + node.ParameterName, "GetImageInfo", "ok"); } } if (cpGetImageInfo.Result != TestResult.Fail) { cpGetImageInfo.Result = TestResult.Pass; cpGetImageInfo.Outputs.AddParameter("Get Image Info return all correct info", "GetImageInfo", rtGetImageInfo.ResultContent); } } #endregion #region Call getImageDescription to check expected key and value CheckPoint cpGetImageDescription = new CheckPoint("GetImageDescription", "Call GetImageDescription to check the info in return value"); r.CheckPoints.Add(cpGetImageDescription); XMLResult rtGetImageDescription = imageSvc.getImageDescription(imageID); if (rtGetImageDescription.IsErrorOccured) { cpGetImageDescription.Result = TestResult.Fail; cpGetImageDescription.Outputs.AddParameter("Get Image Description returns error", "getImageDescription", rtGetImageDescription.ResultContent); } else { cpGetImageDescription.Outputs.AddParameter("Get Image Description return success", "getImageDescription", rtGetImageDescription.Message); //Check the return info contain the expected key and value: parameter key="XXX" value="XXX" foreach (XMLParameterNode node in epGetImageDescription.Parameters) { if (!rtGetImageDescription.ResultContent.Contains("parameter key=\"" + node.ParameterName + "\" value=\"" + node.ParameterValue + "\"")) { cpGetImageDescription.Result = TestResult.Fail; cpGetImageDescription.Outputs.AddParameter("Get Image Description returns wrong key-value info for: " + node.ParameterName, "GetImageDescription", rtGetImageDescription.ResultContent); continue; } else { cpGetImageDescription.Outputs.AddParameter("Get Image Description returns correct key-value info for: " + node.ParameterName, "GetImageDescription", "ok"); } } if (cpGetImageDescription.Result != TestResult.Fail) { cpGetImageDescription.Result = TestResult.Pass; cpGetImageDescription.Outputs.AddParameter("Get Image Description returns all correct info", "GetImageDescription", rtGetImageDescription.ResultContent); } } #endregion } if (isDeletePatient) { CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient"); r.CheckPoints.Add(cpDelete); XMLResult rltDelete = patientSvc.deletePatient(patientUID); if (rltDelete.IsErrorOccured) { cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message); cpDelete.Result = TestResult.Fail; } else { cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.Message); cpDelete.Result = TestResult.Pass; } } 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 1598: 1.1.06.21_ImportDir_MainDirectory_N01 public void Run_Import_ImportDir_MainDirectory_Case1598() { int runCount = 0; NotificationSim.ReceiveNotification rn = new ReceiveNotification(); System.Collections.Generic.List<string> topics = new System.Collections.Generic.List<string>(); topics.Add("topic.postImportCompleted"); string stopTopic = "teststop"; string stopContent = "teststop"; rn.startListon(topics, stopTopic, stopContent); foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "ImportMainDir"); CheckPoint pimp = new CheckPoint("ImportDir", "Import Additional Dir"); r.CheckPoints.Add(pimp); //create patient for import PatientService ps = new PatientService(); XMLParameter cInputPatient = new XMLParameter("patient"); cInputPatient.AddParameter("first_name", "test"); cInputPatient.AddParameter("last_name", "importmaindir"); XMLResult rslCreate = ps.createPatient(cInputPatient); if (rslCreate.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Create Patient Fail", rslCreate.Message); SaveRound(r); continue; } string patientid = rslCreate.SingleResult; try { string kdis6dir = ids.InputParameters.GetParameter("kdis6_dir").Value; int retrynum = int.Parse(ids.InputParameters.GetParameter("retrynum").Value); string flag = "import"; ImportService imps = new ImportService(); XMLResult rslimport = imps.importDir(patientid, kdis6dir, flag); if (rslimport.Code != 800) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Import Fail", rslimport.Message); SaveRound(r); ps.deletePatient(patientid); continue; } int n = 0; while (rn.getRecievedNumber() == 0) { n++; if (n < retrynum) { System.Threading.Thread.Sleep(5000); } else { break; } } if (n == retrynum) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Notification Fail", "No notification recieved after retry " + n.ToString() + " times."); SaveRound(r); ps.deletePatient(patientid); continue; } ApplicationService app = new ApplicationService(); app.sendGenericNotification(stopTopic, stopContent); System.Threading.Thread.Sleep(1000); System.Collections.Generic.List<string> mmm = rn.getNotificationContent(); System.Collections.Generic.List<string> imageids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Image", mmm[0]); System.Collections.Generic.List<string> fmsids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("FMS", mmm[0]); System.Collections.Generic.List<string> analysisids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Analysis", mmm[0]); int expectedimgcount = int.Parse(ids.ExpectedValues.GetParameter("imgnum").Value); int expectedfmscount = int.Parse(ids.ExpectedValues.GetParameter("fmsnum").Value); int expectedanalysiscount = int.Parse(ids.ExpectedValues.GetParameter("analysisnum").Value); //check counts if (imageids.Count != expectedimgcount) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Image Count is not correct", "Actual:" + imageids.Count.ToString() + ",Expected:" + expectedimgcount.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } if (fmsids.Count != expectedfmscount) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "FMS Count is not correct", "Actual:" + fmsids.Count.ToString() + ",Expected:" + expectedfmscount.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } if (analysisids.Count != expectedanalysiscount) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Analysis Count is not correct", "Actual:" + analysisids.Count.ToString() + ",Expected:" + expectedanalysiscount.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //get image info ImageService imgs = new ImageService(); foreach (string imgid in imageids) { XMLParameter cInputImage = new XMLParameter("image"); cInputImage.AddParameter("internal_id", imgid); XMLResult rslget = imgs.getImageInfo(cInputImage); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetImage Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //get FMS info FMSService fmss = new FMSService(); foreach (string fmsid in fmsids) { XMLResult rslget = fmss.getFMSInfo(fmsid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } rslget = fmss.getFMSDescription(fmsid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //get Analysis info AnalysisService anas = new AnalysisService(); foreach (string analysisid in analysisids) { XMLResult rslget = anas.getAnalysisInfo(analysisid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } rslget = anas.getAnalysisDescription(analysisid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //check list object NewPatientService nps = new NewPatientService(); PatientListObjectsRequestType request = new PatientListObjectsRequestType(); request.currentSpecified = true; request.current = true; request.patientInternalId = patientid; request.type = PatientListObjectsType.all; PatientListObjectsResponseType response = nps.listObjects(request); //to refresh code 800 to 0 response = nps.listObjects(request); if (!nps.LastReturnXMLValidateResult.isValid) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail", "Response is not complied with schema"); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.status.code != 0) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,message: ", response.status.message); SaveRound(r); ps.deletePatient(patientid); continue; } int expectedcurrentps = int.Parse(ids.ExpectedValues.GetParameter("curpsnum").Value); int expectedcurrentfms = int.Parse(ids.ExpectedValues.GetParameter("curfmsnum").Value); int expectedcurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("curanalysisnum").Value); if (response.presentationStates.Length != expectedcurrentps) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current image count not correct: ", "actural:" + response.presentationStates.Length.ToString() + " expect:" + expectedcurrentps.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //get PS PresentationStateService pss = new PresentationStateService(); foreach (PresentationStateType pst in response.presentationStates) { XMLResult rslget = pss.getPresentationState(pst.uid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } if (response.analysiss != null) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current analysis count not correct: ", "Expect no analysis will be returned"); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.fmss.Length != expectedcurrentfms) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current fms count not correct: ", "actural:" + response.fmss.Length.ToString() + " expect:" + expectedcurrentfms.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //list noncurrent objects request.currentSpecified = true; request.current = false; request.patientInternalId = patientid; request.type = PatientListObjectsType.all; response = nps.listObjects(request); int expectednoncurrentps = int.Parse(ids.ExpectedValues.GetParameter("noncurpsnum").Value); int expectednoncurrentfms = int.Parse(ids.ExpectedValues.GetParameter("noncurfmsnum").Value); int expectednoncurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("noncuranalysisnum").Value); if (response.presentationStates.Length != expectednoncurrentps) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail, non current ps count not correct: ", "actual:" + response.presentationStates.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //get PS foreach (PresentationStateType pst in response.presentationStates) { XMLResult rslget = pss.getPresentationState(pst.uid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //check 3d object if (response.volumes.Length != int.Parse(ids.ExpectedValues.GetParameter("expect3dnum").Value)) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Import 3d objects fail: ", "Count is " + response.volumes.Length.ToString() + ",expect:" + ids.ExpectedValues.GetParameter("expect3dnum").Value); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.analysiss.Length != expectednoncurrentanalysis) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current analysis count not correct: ", "actual:" + response.analysiss.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.fmss.Length != expectednoncurrentfms) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current fms count not correct: ", "actual:" + response.fmss.Length.ToString() + " expect:" + expectednoncurrentfms.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //Finally the test success pimp.Result = TestResult.Pass; pimp.Outputs.AddParameter("Import Main Dir", "Success", "OK"); SaveRound(r); ps.deletePatient(patientid); } catch (Exception e) { ps.deletePatient(patientid); pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Fail", "Exception caught,message:" + e.Message); SaveRound(r); } } error: Output(); }
// Case 1203: 1.3.10_ImportImage_N07_Import single 8100 dicom thin layer slice public void Run_Import_8100Slice_Case1203() { int runCount = 0; string patientUID = string.Empty; bool isCreatePatient = false; bool isDeletePatient = true; foreach (InputDataSet ids in this.Input.DataSets) { isCreatePatient = false; runCount++; Round r = this.NewRound(runCount.ToString(), "Import image"); ImportService ims = new ImportService(); XMLParameter pa = new XMLParameter("patient"); XMLParameter ia = new XMLParameter("import"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "create") { pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); isCreatePatient = true; } if (ids.InputParameters.GetParameter(i).Step == "import") { ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } string epGetImageInfoImageType = null; string epGetImageInfoAnatomicRegion = null; string epGetImageInfoAnatomicRegionModifiers = null; string epGetPSInfoImageType = null; string epGetPSInfoAnatomicRegion = null; string epGetPSInfoAnatomicRegionModifiers = null; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo") { switch (ids.ExpectedValues.GetParameter(i).Key) { case "image_type": epGetImageInfoImageType = ids.ExpectedValues.GetParameter(i).Value; break; case "dcm_anatomic_region": epGetImageInfoAnatomicRegion = ids.ExpectedValues.GetParameter(i).Value; break; case "dcm_anatomic_region_modifiers": epGetImageInfoAnatomicRegionModifiers = ids.ExpectedValues.GetParameter(i).Value; break; default: break; } } else if (ids.ExpectedValues.GetParameter(i).Step == "getPresentationStateInfo") { switch (ids.ExpectedValues.GetParameter(i).Key) { case "image_type": epGetPSInfoImageType = ids.ExpectedValues.GetParameter(i).Value; break; case "dcm_anatomic_region": epGetPSInfoAnatomicRegion = ids.ExpectedValues.GetParameter(i).Value; break; case "dcm_anatomic_region_modifiers": epGetPSInfoAnatomicRegionModifiers = ids.ExpectedValues.GetParameter(i).Value; break; default: break; } } } try { PatientService patientSvc = new PatientService(); if (isCreatePatient) { CheckPoint pCreate = new CheckPoint("Create Patient", "Test create"); r.CheckPoints.Add(pCreate); XMLResult result = patientSvc.createPatient(pa); if (!result.IsErrorOccured) { patientUID = result.SingleResult; pCreate.Result = TestResult.Pass; pCreate.Outputs.AddParameter("Create patient UID", "Create Patient", patientUID); } else { pCreate.Result = TestResult.Fail; pCreate.Outputs.AddParameter("Create patient returns error", "Create Patient", result.ResultContent); } } CheckPoint pImport = new CheckPoint("Import Image", "Test import"); r.CheckPoints.Add(pImport); string filePath = string.Empty; string archivePath = string.Empty; bool move = false; for (int c = 0; c < ia.Length; c++) { if (ia.GetParameterName(c) == "path") filePath = ia.GetParameterValue(c); if (ia.GetParameterName(c) == "archivePath") archivePath = ia.GetParameterValue(c); if (ia.GetParameterName(c) == "move") { if (ia.GetParameterValue(c) == "true") move = true; } } XMLResult rslImport = ims.importObject(patientUID, "", filePath, archivePath, move, "false"); //import return sample: // <trophy type="result" version="1.0"> // <status code="0" message="ok" /> // <image><parameter key="internal_id" value="2bfb416b-037e-41e7-aaef-8d2bd08b1ae7" /></image> // <presentationstate><parameter key="internal_id" value="75675345-a164-4088-b6d3-1b2ae86b703b" /></presentationstate> // </trophy> if (rslImport.IsErrorOccured) { pImport.Result = TestResult.Fail; pImport.Outputs.AddParameter("Import image fail", "Import", rslImport.Message); pImport.Outputs.AddParameter("Import image returns error code", "Import", rslImport.Code.ToString()); } else { // Check the return contiains image id and ps id string imageID = null; imageID = rslImport.MultiResults[0].GetParameterValueByName("internal_id"); // image internal_id if (imageID == null || imageID == string.Empty) { pImport.Result = TestResult.Fail; pImport.Outputs.AddParameter("Import image returns wrong image internal id", "Import", rslImport.ResultContent); } string psID = null; psID = rslImport.MultiResults[1].GetParameterValueByName("internal_id"); // ps internal_id if (psID == null || psID == string.Empty) { pImport.Result = TestResult.Fail; pImport.Outputs.AddParameter("import image returns wrong ps internal id", "Import", rslImport.ResultContent); } else { pImport.Result = TestResult.Pass; pImport.Outputs.AddParameter("import image returns OK", "Import", rslImport.ResultContent); } #region Call getImageInfo to check image_type and anatomic_region ImageService imageSvc = new ImageService(); PresentationStateService psSvc = new PresentationStateService(); XMLParameter pGetImageInfo = new XMLParameter("image"); pGetImageInfo.AddParameter("internal_id", imageID); CheckPoint cpGetImageInfo = new CheckPoint("GetImageInfo", "Call GetImageInfo to check the dcm_anatomic_region value"); r.CheckPoints.Add(cpGetImageInfo); XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfo); if (rtGetImageInfo.IsErrorOccured) { cpGetImageInfo.Result = TestResult.Fail; cpGetImageInfo.Outputs.AddParameter("Get Image Info return error", "getImageInfo", rtGetImageInfo.ResultContent); } else { cpGetImageInfo.Outputs.AddParameter("Get Image Info return success", "getImageInfo", rtGetImageInfo.Message); // Check the image_type, anatomic_region values in return are correct if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"image_type\" value=\"" + epGetImageInfoImageType + "\"")) //parameter key="image_type" value="PANOV6" { cpGetImageInfo.Result = TestResult.Fail; cpGetImageInfo.Outputs.AddParameter("Get Image Info return wrong image_type info", "getImageInfo", rtGetImageInfo.ResultContent); } else if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region\" value=\"" + epGetImageInfoAnatomicRegion + "\"")) // parameter key="dcm_anatomic_region" value="Jaw region" { cpGetImageInfo.Result = TestResult.Fail; cpGetImageInfo.Outputs.AddParameter("Get Image Info return wrong dcm_anatomic_region info", "getImageInfo", rtGetImageInfo.ResultContent); } else if (!rtGetImageInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region_modifiers\" value=\"" + epGetImageInfoAnatomicRegionModifiers + "\"")) // parameter key="dcm_anatomic_region_modifiers" value="Molar 1" { cpGetImageInfo.Result = TestResult.Fail; cpGetImageInfo.Outputs.AddParameter("Get Image Info return wrong dcm_anatomic_region_modifiers info", "getImageInfo", rtGetImageInfo.ResultContent); } else { cpGetImageInfo.Result = TestResult.Pass; cpGetImageInfo.Outputs.AddParameter("Get Image Info return correct info", "getImageInfo", rtGetImageInfo.ResultContent); } } XMLParameterCollection pGetPSInfo = new XMLParameterCollection(); XMLParameter psList = new XMLParameter("presentationstate"); psList.AddParameter("internal_id", psID); pGetPSInfo.Add(psList); CheckPoint cpGetPSInfo = new CheckPoint("GetPSInfo", "Call GetPSInfo to check the dcm_anatomic_region value"); r.CheckPoints.Add(cpGetPSInfo); XMLResult rtGetPSInfo = psSvc.getPresentationStateInfo(pGetPSInfo); if (rtGetPSInfo.IsErrorOccured) { cpGetPSInfo.Result = TestResult.Fail; cpGetPSInfo.Outputs.AddParameter("Get PS Info return error", "GetPSInfo", rtGetPSInfo.ResultContent); } else { cpGetPSInfo.Outputs.AddParameter("Get PS Info return success", "GetPSInfo", rtGetPSInfo.Message); // Check the image_type, anatomic_region values in return are correct if (!rtGetPSInfo.ResultContent.Contains("parameter key=\"image_type\" value=\"" + epGetPSInfoImageType + "\"")) //parameter key="image_type" value="PANOV6" { cpGetPSInfo.Result = TestResult.Fail; cpGetPSInfo.Outputs.AddParameter("Get PS Info return wrong image_type info", "GetPSInfo", rtGetPSInfo.ResultContent); } else if (!rtGetPSInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region\" value=\"" + epGetPSInfoAnatomicRegion + "\"")) // parameter key="dcm_anatomic_region" value="Jaw region" { cpGetPSInfo.Result = TestResult.Fail; cpGetPSInfo.Outputs.AddParameter("Get PS Info return wrong dcm_anatomic_region info", "GetPSInfo", rtGetPSInfo.ResultContent); } else if (!rtGetPSInfo.ResultContent.Contains("parameter key=\"dcm_anatomic_region_modifiers\" value=\"" + epGetPSInfoAnatomicRegionModifiers + "\"")) // parameter key="dcm_anatomic_region_modifiers" value="Molar 1" { cpGetPSInfo.Result = TestResult.Fail; cpGetPSInfo.Outputs.AddParameter("Get PS Info return wrong dcm_anatomic_region_modifiers info", "GetPSInfo", rtGetPSInfo.ResultContent); } else { cpGetPSInfo.Result = TestResult.Pass; cpGetPSInfo.Outputs.AddParameter("Get PS Info return correct info", "GetPSInfo", rtGetPSInfo.ResultContent); } } CheckPoint cpGetPS = new CheckPoint("GetPS", "Call GetPS to check the ps xml info"); r.CheckPoints.Add(cpGetPS); XMLResult rtGetPS = psSvc.getPresentationState(psID); if (rtGetPS.IsErrorOccured) { cpGetPS.Result = TestResult.Fail; cpGetPS.Outputs.AddParameter("Get PS return error", "GetPS", rtGetPS.ResultContent); } else { cpGetPS.Outputs.AddParameter("Get PS return success", "GetPS", rtGetPS.Message); if (rtGetPS.ResultContent.Contains("parameter key=\"general.xml\"") && rtGetPS.ResultContent.Contains("parameter key=\"processing.xml\"") && rtGetPS.ResultContent.Contains("parameter key=\"annotation.xml\"")) // Should return empty ps info for this case as there is not { cpGetPS.Result = TestResult.Pass; cpGetPS.Outputs.AddParameter("Get PS return correct info", "GetPS", rtGetPS.ResultContent); } else { cpGetPS.Result = TestResult.Fail; cpGetPS.Outputs.AddParameter("Get PS return wrong content", "GetPS", rtGetPS.ResultContent); } } #endregion } if (isDeletePatient) { CheckPoint cpDelete = new CheckPoint("Delete Patient", "Test delete patient"); r.CheckPoints.Add(cpDelete); XMLResult rltDelete = patientSvc.deletePatient(patientUID); if (rltDelete.IsErrorOccured) { cpDelete.Outputs.AddParameter("Delete created patient returns error", "Delete Patient", rltDelete.Message); cpDelete.Result = TestResult.Fail; } else { cpDelete.Outputs.AddParameter("Delete created patient returns OK", "Delete Patient", rltDelete.Message); cpDelete.Result = TestResult.Pass; } } 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 61: 1.3.6_GetCephTracing_Normal public void Run_Image_GetCephTracing_Normal_Case61() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { string imageInternalID = null; // Input parameter XMLParameter getCephTracingParam = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "getCephTracing") { if (ids.InputParameters.GetParameter(i).Key == "imageInternalID") { imageInternalID = ids.InputParameters.GetParameter(i).Value; } } } //Output value bool ep_isReturnOK = true; string ep_ReturnValue = null; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getCephTracing") { if (ids.ExpectedValues.GetParameter(i).Key.ToLower().Equals("state")) { if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("pass")) { ep_isReturnOK = true; } else if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("fail")) { ep_isReturnOK = false; } } else if (ids.ExpectedValues.GetParameter(i).Key.ToLower().Equals("returnvalue")) { ep_ReturnValue = ids.ExpectedValues.GetParameter(i).Value; } } } #region Step 1: Call ImageService.getCephTracing to get the Ceph tracing info CheckPoint pGetCephTracing = new CheckPoint("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info"); r.CheckPoints.Add(pGetCephTracing); ImageService imageService = new ImageService(); XMLResult getCephTracingResult = imageService.getCephTracing(imageInternalID); if (ep_isReturnOK) // Expect the call returns ok { if (getCephTracingResult.IsErrorOccured) { pGetCephTracing.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.getCephTracing to get the Ceph tracing info returns error."); pGetCephTracing.Outputs.AddParameter("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info", getCephTracingResult.Message); SaveRound(r); break; // There is error, end test case } else { // Check the return value if (String.Equals(getCephTracingResult.SingleResult.Replace("\n", "").Replace("\r", ""), ep_ReturnValue.Replace("\n", "").Replace("\r", ""))) { pGetCephTracing.Result = TestResult.Pass; System.Diagnostics.Debug.Print("Call ImageService.getCephTracing to get the Ceph tracing info succeeds."); pGetCephTracing.Outputs.AddParameter("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info", getCephTracingResult.Message); } else { pGetCephTracing.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.getCephTracing to get the Ceph tracing info return value is not correct."); pGetCephTracing.Outputs.AddParameter("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info return value is not correct", "Expect: " + ep_ReturnValue + "\n\n\n Actually Get: " + getCephTracingResult.SingleResult); } } } else // Expect the call returns error { if (getCephTracingResult.IsErrorOccured) { // Check the return value if (getCephTracingResult.Message.Contains(ep_ReturnValue)) { pGetCephTracing.Result = TestResult.Pass; System.Diagnostics.Debug.Print("Call ImageService.getCephTracing to get the Ceph tracing info returns error as expected."); pGetCephTracing.Outputs.AddParameter("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info returns error as expected", getCephTracingResult.Message); } else { pGetCephTracing.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.getCephTracing to get the Ceph tracing info not returns error as expected."); pGetCephTracing.Outputs.AddParameter("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info not returns error as expected", "Expect: " + ep_ReturnValue + "; Actually Get: " + getCephTracingResult.Message); } } else { pGetCephTracing.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.getCephTracing to get the Ceph tracing info not returns error as expected."); pGetCephTracing.Outputs.AddParameter("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info not returns error as expected", getCephTracingResult.Message); SaveRound(r); break; // There is error, end test case } } #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 46: 1.3.6_ListPresentationStates_Normal public void Run_Image_ListPresentationStates_Normal_Case46() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { string imageInternalID = null; ImageService imageService = new ImageService(); #region Initialize parameter // Input parameter XMLParameter p_listPSFilter = new XMLParameter("filter"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "listPresentationState") { if (ids.InputParameters.GetParameter(i).Key == "imageInternalID") { imageInternalID = ids.InputParameters.GetParameter(i).Value; } else if (ids.InputParameters.GetParameter(i).Key == "filter") { p_listPSFilter.AddParameter("current", ids.InputParameters.GetParameter(i).Value); } } } //Output value bool ep_isReturnOK = true; string ep_returnMessage = string.Empty; XMLParameter ep_listPresentationState = new XMLParameter("presentationstate"); for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "listPresentationState") { if (ids.ExpectedValues.GetParameter(i).Key == "returnState") { if (ids.ExpectedValues.GetParameter(i).Value.ToLower() == "pass") { ep_isReturnOK = true; } else if (ids.ExpectedValues.GetParameter(i).Value.ToLower() == "fail") { ep_isReturnOK = false; } } else if (ids.ExpectedValues.GetParameter(i).Key == "returnMessage") { ep_returnMessage = ids.ExpectedValues.GetParameter(i).Value; } else if (ids.ExpectedValues.GetParameter(i).Key == "internal_id") { ep_listPresentationState.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } } #endregion #region Step 1: Call ImageService.listPresentationState to list presentationState CheckPoint cp_listPresentationState = new CheckPoint("listPresentationState", "Call ImageService.listPresentationState to list presentationState"); r.CheckPoints.Add(cp_listPresentationState); XMLResult rt_listPresentationState = imageService.listPresentationState(p_listPSFilter, imageInternalID); if (ep_isReturnOK) // Expect the call returns ok { if (rt_listPresentationState.IsErrorOccured) { cp_listPresentationState.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.listPresentationState to list presentationState returns error."); cp_listPresentationState.Outputs.AddParameter("listPresentationState", "Call ImageService.listPresentationState to list presentationState", rt_listPresentationState.Message); SaveRound(r); continue; // There is error, end current round and test case } else { // Check the return value bool isPSCorrect = false; int i = 0; for (i = 0; i < ep_listPresentationState.Parameters.Count; i++) { isPSCorrect = rt_listPresentationState.ResultContent.Contains(ep_listPresentationState.Parameters[i].ParameterValue); if (!isPSCorrect) { break; // stop compare and keep the index to report which one is not shown } } if (isPSCorrect) { cp_listPresentationState.Result = TestResult.Pass; System.Diagnostics.Debug.Print("Call ImageService.listPresentationState to list presentationState succeeds and the PS info is correct."); cp_listPresentationState.Outputs.AddParameter("listPresentationState", "Call ImageService.listPresentationState to list presentationState", rt_listPresentationState.Message); } else { cp_listPresentationState.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.listPresentationState to list presentationState return value is not correct."); cp_listPresentationState.Outputs.AddParameter("listPresentationState", "Call ImageService.listPresentationState to list presentationState return value is not correct", "Expect PS: " + ep_listPresentationState.Parameters[i].ParameterValue + " to show in the return. Actually Get: " + rt_listPresentationState.ResultContent); } } } else // Expect the call returns error { if (rt_listPresentationState.IsErrorOccured) { // Check the return value if (rt_listPresentationState.Message.Contains(ep_returnMessage)) { cp_listPresentationState.Result = TestResult.Pass; System.Diagnostics.Debug.Print("Call ImageService.listPresentationState to list presentationState returns error as expected."); cp_listPresentationState.Outputs.AddParameter("listPresentationState", "Call ImageService.listPresentationState to list presentationState returns error as expected", rt_listPresentationState.Message); } else { cp_listPresentationState.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.listPresentationState to list presentationState not returns error as expected."); cp_listPresentationState.Outputs.AddParameter("listPresentationState", "Call ImageService.listPresentationState to list presentationState not returns error as expected", "Expect: " + ep_returnMessage + "; Actually Get: " + rt_listPresentationState.Message); } } else { cp_listPresentationState.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.listPresentationState to list presentationState not returns error as expected."); cp_listPresentationState.Outputs.AddParameter("listPresentationState", "Call ImageService.listPresentationState to list presentationState not returns error as expected", rt_listPresentationState.Message); SaveRound(r); continue; // There is error, end test case } } #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 103: 1.3.6_GetImageDescription_Exception public void Run_Image_GetImageDescription_Exception_Case103() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { string imageID = null; // Input parameter XMLParameter pGetImageDescription = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "getImageDescription") { if (ids.InputParameters.GetParameter(i).Key == "internal_id") { imageID = ids.InputParameters.GetParameter(i).Value; } } } // Output value string epErrorCode = string.Empty; string epErrorMessage = string.Empty; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Key == "error_code") { epErrorCode = ids.ExpectedValues.GetParameter(i).Value; } else if (ids.ExpectedValues.GetParameter(i).Key == "error_message") { epErrorMessage = ids.ExpectedValues.GetParameter(i).Value; } } #region Step 1: Call ImageService.getImageDescription to get the image description CheckPoint cpGetImageDescription = new CheckPoint("getImageDescription", "Call ImageService.getImageDescription to get the image description"); r.CheckPoints.Add(cpGetImageDescription); ImageService imageService = new ImageService(); XMLResult rtGetImageDescription = imageService.getImageDescription(imageID); if (rtGetImageDescription.IsErrorOccured) { if (rtGetImageDescription.Code.ToString() == epErrorCode && rtGetImageDescription.Message.Contains(epErrorMessage)) { cpGetImageDescription.Result = TestResult.Pass; cpGetImageDescription.Outputs.AddParameter("getImageDescription", "Call ImageService.getImageDescription returns error as expected", rtGetImageDescription.Message); } else { cpGetImageDescription.Result = TestResult.Fail; cpGetImageDescription.Outputs.AddParameter("getImageDescription", "Call ImageService.getImageDescription doesn't returns the expected error", "Error Code: " + rtGetImageDescription.Code + "; Error Message: " + rtGetImageDescription.Message); SaveRound(r); break; // There is error, end test case } } else { cpGetImageDescription.Result = TestResult.Fail; cpGetImageDescription.Outputs.AddParameter("getImageDescription", "Call ImageService.getImageDescription doesn't returns the expected error", rtGetImageDescription.Message); SaveRound(r); break; // There is error, end test case } #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 111: 1.3.6_SetCephTracing_Normal public void Run_Image_SetCephTracing_Normal_Case111() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Test Image Service: createImage -> getImageInfo & getImageDescription -> setImageInfo -> getImageInfo & getImageDescription -> deleteImage"); try { string imageinternalUid = null; ImageService imageService = new ImageService(); #region Parameter Initialize //Input parameter XMLParameter p_CreateImage = new XMLParameter("image"); string p_SetCephTracing = null; for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "createImage") { p_CreateImage.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "setCephTracing" && ids.InputParameters.GetParameter(i).Key == "cephTracing") { p_SetCephTracing = ids.InputParameters.GetParameter(i).Value; } } //Output value string ep_GetCephTraingReturn = null; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getCephTracing" && ids.ExpectedValues.GetParameter(i).Key == "cephTracing") { ep_GetCephTraingReturn = ids.ExpectedValues.GetParameter(i).Value; } } #endregion #region Step 1: Call ImageService.createImage to create a new image CheckPoint cp_CreateImage = new CheckPoint("Image create", "Call imageService.createImage to create a new image"); r.CheckPoints.Add(cp_CreateImage); XMLResult rt_CreateImage = imageService.createImage(p_CreateImage); if (rt_CreateImage.IsErrorOccured) { cp_CreateImage.Result = TestResult.Fail; cp_CreateImage.Outputs.AddParameter("create", "Create image returns error", rt_CreateImage.Message); SaveRound(r); break; // There is error, end test case } else { cp_CreateImage.Result = TestResult.Pass; cp_CreateImage.Outputs.AddParameter("create", "Create image returns success", rt_CreateImage.Message); imageinternalUid = rt_CreateImage.SingleResult; } #endregion #region Step 2: Call ImageService.setCephTracing to set the Ceph Tracing CheckPoint cp_SetCephTracing = new CheckPoint("Set cephTracing", "Call imageService.setCephTracing to set the cephTracing"); r.CheckPoints.Add(cp_SetCephTracing); XMLResult rt_SetCephTracing = imageService.setCephTracing(p_SetCephTracing, imageinternalUid); if (rt_SetCephTracing.IsErrorOccured) { cp_SetCephTracing.Result = TestResult.Fail; cp_SetCephTracing.Outputs.AddParameter("setCephTracing", "Call imageService.setCephTracing returns error", rt_SetCephTracing.Message); SaveRound(r); break; // There is error, end test case } else { cp_SetCephTracing.Result = TestResult.Pass; cp_SetCephTracing.Outputs.AddParameter("setCephTracing", "Call imageService.setCephTracing returns success", rt_SetCephTracing.Message); } #endregion #region Step 3: Call ImageService.getCephTracing to get the Ceph tracing info CheckPoint cp_GetCephTracing = new CheckPoint("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info"); r.CheckPoints.Add(cp_GetCephTracing); XMLResult getCephTracingResult = imageService.getCephTracing(imageinternalUid); if (getCephTracingResult.IsErrorOccured) { cp_GetCephTracing.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.getCephTracing to get the Ceph tracing info returns error."); cp_GetCephTracing.Outputs.AddParameter("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info", getCephTracingResult.Message); SaveRound(r); break; // There is error, end test case } else { // Check the return value if (String.Equals(getCephTracingResult.SingleResult.Replace("\n", "").Replace("\r", ""), ep_GetCephTraingReturn.Replace("\n", "").Replace("\r", ""))) { cp_GetCephTracing.Result = TestResult.Pass; System.Diagnostics.Debug.Print("Call ImageService.getCephTracing to get the Ceph tracing info succeeds."); cp_GetCephTracing.Outputs.AddParameter("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info", getCephTracingResult.Message); } else { cp_GetCephTracing.Result = TestResult.Fail; System.Diagnostics.Debug.Print("Call ImageService.getCephTracing to get the Ceph tracing info return value is not correct."); cp_GetCephTracing.Outputs.AddParameter("getCephTracing", "Call ImageService.getCephTracing to get the Ceph tracing info return value is not correct", "Expect: " + ep_GetCephTraingReturn + "\n\n\n Actually Get: " + getCephTracingResult.SingleResult); } } #endregion #region Step 4: Call ImageService.deleteImage to delete the image CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image"); r.CheckPoints.Add(cp_DeleteImage); XMLResult rt_DeleteImage = imageService.deleteImage(imageinternalUid, new XMLParameter("preferences")); if (rt_DeleteImage.IsErrorOccured) { cp_DeleteImage.Result = TestResult.Fail; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message); SaveRound(r); break; // There is error, end test case } else { cp_DeleteImage.Result = TestResult.Pass; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message); } #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 198: 1.3.6_GetImageInfo_Exception public void Run_Image_GetImageInfo_Exception_Case198() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { // Input parameter XMLParameter getImageInfoParam = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Key == "internal_id") { getImageInfoParam.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } // Output value string epErrorCode = string.Empty; string epErrorMessage = string.Empty; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Key == "error_code") { epErrorCode = ids.ExpectedValues.GetParameter(i).Value; } else if (ids.ExpectedValues.GetParameter(i).Key == "error_message") { epErrorMessage = ids.ExpectedValues.GetParameter(i).Value; } } #region Step 1: Call ImageService.getImageInfo to get the image info CheckPoint pGetImageInfo = new CheckPoint("getImageInfo", "Call ImageService.getImageInfo to get the image info"); r.CheckPoints.Add(pGetImageInfo); ImageService imageService = new ImageService(); XMLResult getImageInfoResult = imageService.getImageInfo(getImageInfoParam); if (getImageInfoResult.IsErrorOccured) { if (getImageInfoResult.Code.ToString() == epErrorCode && getImageInfoResult.Message.Contains(epErrorMessage)) { pGetImageInfo.Result = TestResult.Pass; pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo returns error as expected", "Return Code: " + getImageInfoResult.Code + "; Return message: " + getImageInfoResult.Message); } else { pGetImageInfo.Result = TestResult.Fail; pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo doesnot return error as expected", "Return Code: " + getImageInfoResult.Code + "; Return message: " + getImageInfoResult.Message); SaveRound(r); break; // There is error, end test case } } else { pGetImageInfo.Result = TestResult.Fail; pGetImageInfo.Outputs.AddParameter("getImageInfo", "Call ImageService.getImageInfo doesnot return error", "Return Code: " + getImageInfoResult.Code + "; Return message: " + getImageInfoResult.Message); SaveRound(r); break; // There is error, end test case } #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 55: 1.3.6_DeleteImage_Normal public void Run_Image_DeleteImage_Normal_Case55() { int runCount = 0; string patientUID = string.Empty; string imageUID = string.Empty; bool isCreatePatient = false; foreach (InputDataSet ids in this.Input.DataSets) { isCreatePatient = false; runCount++; Round r = this.NewRound(runCount.ToString(), "Create image"); CheckPoint pCreate = new CheckPoint("Create patient", "Test create"); r.CheckPoints.Add(pCreate); PatientService ps = new PatientService(); ImageService ims = new ImageService(); XMLParameter pa = new XMLParameter("patient"); XMLParameter ia = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "create") { pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); isCreatePatient = true; } if (ids.InputParameters.GetParameter(i).Step == "image") { ia.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } if (isCreatePatient) { XMLResult result = ps.createPatient(pa); if (!result.IsErrorOccured) { patientUID = result.SingleResult; pCreate.Result = TestResult.Pass; pCreate.Outputs.AddParameter("create", "Create patient UID", patientUID); } else { pCreate.Result = TestResult.Pass; pCreate.Outputs.AddParameter("create", "Create patient return error: ", result.ResultContent); } } CheckPoint cpCreateImage = new CheckPoint("Image create", "Test image"); r.CheckPoints.Add(cpCreateImage); if (patientUID != null) { ia.AddParameter("patient_internal_id", patientUID); XMLResult imageRsl = ims.createImage(ia); if (imageRsl.IsErrorOccured) { cpCreateImage.Result = TestResult.Fail; cpCreateImage.Outputs.AddParameter("create", "Create image error", imageRsl.Message); } else { cpCreateImage.Result = TestResult.Pass; cpCreateImage.Outputs.AddParameter("create", "Create image Id", imageUID); imageUID = imageRsl.SingleResult; } } if (imageUID != null) { CheckPoint cpDeleteImage = new CheckPoint("Image delete", "Test image"); r.CheckPoints.Add(cpDeleteImage); XMLParameter deletePreference = new XMLParameter("preferences"); deletePreference.AddParameter("completedFlag", "true"); XMLResult delImageRsl = ims.deleteImage(imageUID, deletePreference); if (delImageRsl.IsErrorOccured) { cpDeleteImage.Result = TestResult.Fail; cpDeleteImage.Outputs.AddParameter("delete", "delete image error", delImageRsl.Message); } else { cpDeleteImage.Result = TestResult.Pass; cpDeleteImage.Outputs.AddParameter("delete", "delete image success", delImageRsl.Message); } } if (!string.IsNullOrEmpty(patientUID)) { ps.deletePatient(patientUID); } SaveRound(r); } Output(); }
//Case 158: 1.3.8_GetFMSIndexedInfo_Normal public void Run_FMS_GetFMSIndexedInfo_Normal_Case158() { int runCount = 0; string acquireType = string.Empty; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Acquisition"); AcquisitionService acqs = new AcquisitionService(); FMSService fmss = new FMSService(); ImageService igs = new ImageService(); PresentationStateService pss = new PresentationStateService(); XMLParameter acq = new XMLParameter("acq_info"); XMLParameter FmsInfo = new XMLParameter("fms"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "acquire") { acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "acquireType") { acquireType = ids.InputParameters.GetParameter(i).Key; } if (ids.InputParameters.GetParameter(i).Step == "FMSInfo") { FmsInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } CheckPoint pAcquire = new CheckPoint("Acquire Image", "Acquisition FMS"); r.CheckPoints.Add(pAcquire); System.Diagnostics.Debug.Print("Acquire start"); XMLResult rslAcqRVG = acqs.startAcquisition(acq); System.Threading.Thread.Sleep(3000); switch (acquireType) { case "FMS": System.Diagnostics.Debug.Print("FMS Acquire"); Utility.AcqFMS(22, 60); break; default: System.Diagnostics.Debug.Print("NOT FMS/PANO/CEPH/CR Acquire"); break; } if (rslAcqRVG.IsErrorOccured) { System.Diagnostics.Debug.Print("Acquire fail:"); pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcqRVG.Message); } else { pAcquire.Outputs.AddParameter("Acquire session ID", "startAcquisition", rslAcqRVG.SingleResult); int DORVGcount = 0; XMLResult getAcqRVG = new XMLResult(); do { System.Threading.Thread.Sleep(3000); System.Diagnostics.Debug.Print("get acquire in do"); DORVGcount++; getAcqRVG = acqs.getAcquisitionResult(rslAcqRVG.SingleResult); if (!getAcqRVG.IsErrorOccured) { ParseXMLContent parser = new ParseXMLContent(getAcqRVG.ResultContent); // To parse the return XML string fmsID = parser.getStringWithPathAndType("trophy/object_info", "fms", "value"); string[] fmsIDs = fmsID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int fmsCount = fmsIDs.Length; string imageID = parser.getStringWithPathAndType("trophy/object_info", "image", "value"); string[] imageIDs = imageID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int imageCount = imageIDs.Length; string psID = parser.getStringWithPathAndType("trophy/object_info", "presentation_state", "value"); string[] psIDs = psID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int psCount = psIDs.Length; if (fmsCount == 1 && imageCount >= 1 && psCount >= 1 && imageCount == psCount) { pAcquire.Result = TestResult.Pass; pAcquire.Outputs.AddParameter("getAcquisitionResult", "Acquisition", getAcqRVG.ResultContent); string FMSInternalID = fmsIDs[0]; CheckPoint pFMS = new CheckPoint("Set FMS Info", "FMS Service"); r.CheckPoints.Add(pFMS); XMLResult rslSetFmsInfo = fmss.setFMSInfo(FmsInfo, FMSInternalID); if (rslSetFmsInfo.IsErrorOccured) { pFMS.Result = TestResult.Fail; pFMS.Outputs.AddParameter("Set FMS Result", "FMS Service", rslSetFmsInfo.ResultContent); } XMLResult rslGetFmsInfo = fmss.getFMSInfo(FMSInternalID); if (rslGetFmsInfo.IsErrorOccured) { pFMS.Result = TestResult.Fail; pFMS.Outputs.AddParameter("Get FMS Info Fail", "FMS Service", rslGetFmsInfo.ResultContent); } else { pFMS.Result = TestResult.Pass; pFMS.Outputs.AddParameter("Get FMS Info Result", "FMS Service", rslGetFmsInfo.ResultContent); int matchGetItem = 0; for (int setI = 0; setI < FmsInfo.Length; setI++) { for (int getI = 0; getI < rslGetFmsInfo.MultiResults[0].Parameters.Count; getI++) { if (rslGetFmsInfo.MultiResults[0].Parameters[getI].ParameterName == FmsInfo.Parameters[setI].ParameterName && rslGetFmsInfo.MultiResults[0].Parameters[getI].ParameterValue == FmsInfo.Parameters[setI].ParameterValue) matchGetItem++; } } if (matchGetItem == FmsInfo.Length) { pFMS.Result = TestResult.Pass; pFMS.Outputs.AddParameter("Get FMS Info Result Match Setting", "FMS Service", "Success"); } else { pFMS.Result = TestResult.Fail; pFMS.Outputs.AddParameter("Get FMS Info Result Not Match Setting", "FMS Service", "Failure"); } } XMLResult delFmsRls = fmss.deleteFMS("true", FMSInternalID); if (delFmsRls.IsErrorOccured) { pFMS.Result = TestResult.Fail; pFMS.Outputs.AddParameter("Delete FMS Result", "FMS Service", delFmsRls.Message); pFMS.Outputs.AddParameter("Delete FMS", "FMS Service", "Delete FMS Error"); break; } pFMS.Outputs.AddParameter("Delete FMS Result", "FMS Service", delFmsRls.ResultContent); pFMS.Outputs.AddParameter("Delete FMS and images", "FMS Service", "All images and fms has been deleted"); } else { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("getAcquisitionResult", "FMS Service", "No Image or PS id return"); } break; } if (getAcqRVG.Code != 0 && getAcqRVG.Code != 499) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", getAcqRVG.Message); break; } if (getAcqRVG.IsErrorOccured && getAcqRVG.Code != 499) continue; System.Diagnostics.Debug.Print("get acquireResult:" + DORVGcount); if (DORVGcount > 60) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Get acquire image error", "getAcquisitionResult", "Acquire great with 3 minutes, timeout!"); break; } } while (true); } SaveRound(r); } Output(); }
// Case 1558: 1.1.04.01 SetImage_N01_Call setImage when the original archived image file is accessible public void Run_Image_SetInfo_Normal_Case1558() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { #region Parameter initialize string patientInternalId = string.Empty; string objectFileFullPath = string.Empty; string archivePath = string.Empty; XMLParameter pSetImageInfo = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "importImage") { if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath") { objectFileFullPath = ids.InputParameters.GetParameter(i).Value; } else if (ids.InputParameters.GetParameter(i).Key == "archivePath") { archivePath = ids.InputParameters.GetParameter(i).Value; } } else if (ids.InputParameters.GetParameter(i).Step == "setImageInfo") { pSetImageInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } #endregion #region Step 0: Create a patient for import patientInternalId = PatientService.Utility_CreatePatientForSpecificCase("case1558"); if (string.IsNullOrEmpty(patientInternalId)) { goto CLEANUP; } #endregion string imageInternalID = string.Empty; string currentPSID = string.Empty; ImportService importService = new ImportService(); #region Step 1: Call ImportService.importObject to import a image CheckPoint cpImportImage = new CheckPoint("Import Image", "Call ImportService.importObject to import an archived image"); r.CheckPoints.Add(cpImportImage); XMLResult rtImportImage = importService.importObject(patientInternalId, null, objectFileFullPath, archivePath, true, "false"); if (rtImportImage.IsErrorOccured) { cpImportImage.Result = TestResult.Fail; cpImportImage.Outputs.AddParameter("Import image returns error", "Import image", rtImportImage.Message); SaveRound(r); continue; // There is error when create image, end current run } else { cpImportImage.Result = TestResult.Pass; cpImportImage.Outputs.AddParameter("Import image returns success", "Import image", rtImportImage.Message); imageInternalID = rtImportImage.MultiResults[0].Parameters[0].ParameterValue; currentPSID = rtImportImage.MultiResults[1].Parameters[0].ParameterValue; } #endregion string imagePathAfterImport = string.Empty; string archivedPathAfterImport = string.Empty; string archiveTagAfterImport = string.Empty; ImageService imageSvc = new ImageService(); #region Step 2-1: Check the getImageDescription return is correct after import image CheckPoint cpGetImageDescriptionAfterImport = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after import image"); r.CheckPoints.Add(cpGetImageDescriptionAfterImport); XMLResult rtGetImageDescriptionAfterImport = imageSvc.getImageDescription(imageInternalID); imagePathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("path"); archivedPathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("archive_path"); archiveTagAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("tags"); if (string.IsNullOrEmpty(imagePathAfterImport) && archivedPathAfterImport.Equals(archivePath) && string.IsNullOrEmpty(archiveTagAfterImport)) //getImageDescription should return not tags info { cpGetImageDescriptionAfterImport.Result = TestResult.Pass; cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after import image" + rtGetImageDescriptionAfterImport.ResultContent); } else { cpGetImageDescriptionAfterImport.Result = TestResult.Fail; cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after import image. Actually get: " + rtGetImageDescriptionAfterImport.ResultContent); } #endregion #region Step 2-2: Check the info is correct in getImageInfo return after import image CheckPoint cpGetImageInfoAfterImport = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not import the image"); r.CheckPoints.Add(cpGetImageInfoAfterImport); XMLParameter pGetImageInfoAfterImport = new XMLParameter("image"); pGetImageInfoAfterImport.AddParameter("internal_id", imageInternalID); XMLResult rtGetImageInfo = imageSvc.getImageInfo(pGetImageInfoAfterImport); imagePathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("path"); archivedPathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("archive_path"); archiveTagAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("tags"); if (string.IsNullOrEmpty(imagePathAfterImport) && string.IsNullOrEmpty(archivedPathAfterImport) && string.IsNullOrEmpty(archiveTagAfterImport)) //&& archivePath.Equals(archivedPathAfterImport) && archiveTagAfterImport == "archived", will be supported in new service { cpGetImageInfoAfterImport.Result = TestResult.Pass; cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after import image." + rtGetImageInfo.ResultContent); } else { cpGetImageInfoAfterImport.Result = TestResult.Fail; cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after import image. Actually get: " + rtGetImageInfo.ResultContent); } #endregion #region Step 2-3: Check the image info in listObject retrun after import, such as path, archivePath and tags CheckPoint cpListObject = new CheckPoint("listObjects", "Call PatientService.listObjects to check the archive tag"); r.CheckPoints.Add(cpListObject); NewPatientService patientSvcV2 = new NewPatientService(); PatientListObjectsRequestType pListObjects = new PatientListObjectsRequestType(); pListObjects.current = true; pListObjects.currentSpecified = true; pListObjects.patientInternalId = patientInternalId; pListObjects.type = PatientListObjectsType.presentationState; PatientListObjectsResponseType rtListObjectAfterImport = patientSvcV2.listObjects(pListObjects); if (!patientSvcV2.LastReturnXMLValidateResult.isValid) { cpListObject.Result = TestResult.Fail; cpListObject.Outputs.AddParameter("listObjects", "Check listObjects after import", "The listObjects return XML is not valid per XSD. Returned:" + patientSvcV2.LastReturnXML); } else { bool isArchivePathCorrect = string.Equals(rtListObjectAfterImport.presentationStates[0].image.archivePath, archivePath); bool isPathCorrect = string.IsNullOrEmpty(rtListObjectAfterImport.presentationStates[0].image.path); bool isTagCorrect = string.Equals(rtListObjectAfterImport.presentationStates[0].image.tags, "archived"); if (!isArchivePathCorrect || !isTagCorrect || !isPathCorrect) { cpListObject.Result = TestResult.Fail; cpListObject.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag or archivedPath info is wrong in the return. Actually get: " + patientSvcV2.LastReturnXML); } else { cpListObject.Result = TestResult.Pass; cpListObject.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag and archivedPath info is correct in the return."); } } #endregion #region Step 3: Call ImageService.SetImageInfo to save the archived image as normal image CheckPoint cpSetImageInfo = new CheckPoint("Set Image Info", "Call ImageService.SetImageInfo to save the archived image as normal image"); r.CheckPoints.Add(cpSetImageInfo); XMLResult rtSetImageInfo = imageSvc.setImageInfo(pSetImageInfo, imageInternalID); if (rtSetImageInfo.IsErrorOccured) { cpSetImageInfo.Result = TestResult.Fail; cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns error", "SetImageInfo", rtSetImageInfo.Message); } else { cpSetImageInfo.Result = TestResult.Pass; cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns success", "SetImageInfo", rtSetImageInfo.Message); #endregion // Wait the file is transferred to server DB System.Threading.Thread.Sleep(3000); // Below to check the info is correct after setImageInfo. Check points includes: //1. The Image ID and PS ID are not changed //2. GetImageDescription return correct image path and archive path, correct archive flag //3. GetImageInfo return correct image path, correct archive flag //4. Use the image path to check the image file is in server DB //5. The original archived image is not deleted //6. The listObject return contains correct archive tag #region Step 4: Check the ps is set, not newly created after set image CheckPoint cpPSID = new CheckPoint("Check PS ID", "Check the PS ID is not changed after call setImageInfo"); r.CheckPoints.Add(cpPSID); XMLParameter pListPS = new XMLParameter("filter"); pListPS.AddParameter("current", "true"); string currentPSIDAfterSet = imageSvc.listPresentationState(pListPS, imageInternalID).SingleResult; if (currentPSIDAfterSet == currentPSID) { cpPSID.Result = TestResult.Pass; cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is not changed"); } else { cpPSID.Result = TestResult.Fail; cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is changed. Expect: " + currentPSID + "; Actually new PS ID: " + currentPSIDAfterSet); } #endregion string imagePathAfterSet = string.Empty; string archivePathAfterSet = string.Empty; string archivedTagAfterSet = string.Empty; #region Step 5: Check the getImageDescription return is correct after set image CheckPoint cpGetImageDescriptionAfterSet = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after call setImageInfo"); r.CheckPoints.Add(cpGetImageDescriptionAfterSet); XMLResult rtGetImageDescriptionAfterSet = imageSvc.getImageDescription(imageInternalID); imagePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("path"); archivePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("archive_path"); archivedTagAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("tags"); if (imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archivedTagAfterSet)) // imagePathAfterSet sampe: C:/Documents and Settings/All Users/Application Data/TW/PAS/pas_data/patient/03/8af0a7e63310cc65013310d46d0e0003/1956bc28-ca5e-4720-a857-d4de18fc1479/02962f27-e4be-4d59-b112-9663a2f2572b.dcm" { cpGetImageDescriptionAfterSet.Result = TestResult.Pass; cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after set image"); } else { cpGetImageDescriptionAfterSet.Result = TestResult.Fail; cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after set image. Actually get: " + rtGetImageDescriptionAfterSet.ResultContent); } #endregion #region Step 6: Check the getImageinfo return is correct after set image CheckPoint cpGetImageInfoAfterSet = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not after call setImageInfo"); r.CheckPoints.Add(cpGetImageInfoAfterSet); XMLParameter pGetImageInfoAfterSet = new XMLParameter("image"); pGetImageInfoAfterSet.AddParameter("internal_id", imageInternalID); XMLResult rtGetImageInfoAfterSet = imageSvc.getImageInfo(pGetImageInfoAfterSet); imagePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("path"); archivePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("archive_path"); archivedTagAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("tags"); if (imagePathAfterSet.Contains(Utility.GetCSDMConfig(CSDMConfigSection.local, "patientDirectory")) && imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archivedTagAfterSet)) { cpGetImageInfoAfterSet.Result = TestResult.Pass; cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after set image"); } else { cpGetImageInfoAfterSet.Result = TestResult.Fail; cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after set image. Actually get: " + rtGetImageInfoAfterSet.ResultContent); } #endregion #region Step 7: Check the file exist in server DB CheckPoint cpImageInDB = new CheckPoint("Check file in DB", "Check the file exist in server DB after call setImageInfo"); r.CheckPoints.Add(cpImageInDB); if (Utility.IsImageExistInServerDB(imagePathAfterSet)) { cpImageInDB.Result = TestResult.Pass; cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File exist"); } else { cpImageInDB.Result = TestResult.Fail; cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File NOT exist"); } #endregion #region Step 8: Check the original archived image is not deleted CheckPoint cpOriginalArchivedImage = new CheckPoint("Check original archived file", "Check the original archived image is not deleted after call setImageInfo"); r.CheckPoints.Add(cpOriginalArchivedImage); if (System.IO.File.Exists(archivePath)) { cpOriginalArchivedImage.Result = TestResult.Pass; cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File exist"); } else { cpOriginalArchivedImage.Result = TestResult.Fail; cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File NOT exist"); } #endregion #region Step 9: Check the image info in listObject retrun after set, such as path, archivePath and tags CheckPoint cpListObjectAfterSet = new CheckPoint("listObjects", "Call PatientService.listObjects to check the archive tag after set"); r.CheckPoints.Add(cpListObjectAfterSet); PatientListObjectsResponseType rtListObjectAfterSet = patientSvcV2.listObjects(pListObjects); if (!patientSvcV2.LastReturnXMLValidateResult.isValid) { cpListObjectAfterSet.Result = TestResult.Fail; cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check listObjects after set", "The listObjects return XML is not valid per XSD. Returned:" + patientSvcV2.LastReturnXML); } else { //bool isPathCorrect = rtListObjectAfterSet.presentationStates[0].image.path.Contains(Utility.GetCSDMConfig(CSDMConfigSection.remote, "patientDirectory")) && rtListObjectAfterSet.presentationStates[0].image.path.Contains(imageInternalID); bool isArchivePathCorrect = string.IsNullOrEmpty(rtListObjectAfterSet.presentationStates[0].image.archivePath); bool isTagCorrect = string.IsNullOrEmpty(rtListObjectAfterSet.presentationStates[0].image.tags); if (!isArchivePathCorrect) { cpListObjectAfterSet.Result = TestResult.Fail; cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The archivedPath info is wrong in the return. Actually get: " + patientSvcV2.LastReturnXML); } else if (!isTagCorrect) { cpListObjectAfterSet.Result = TestResult.Fail; cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag info is wrong in the return. Actually get: " + patientSvcV2.LastReturnXML); } //else if (!isPathCorrect) //{ // cpListObjectAfterSet.Result = TestResult.Fail; // cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The path info is wrong in the return. Actually get: " + patientSvc.LastReturnXML); //} else { cpListObjectAfterSet.Result = TestResult.Pass; cpListObjectAfterSet.Outputs.AddParameter("listObjects", "Check the image info in the listObject return value", "The tag and archivedPath info is correct in the return."); } } #endregion } #region Step 10: Call ImageService.deleteImage to delete the created image if (!string.IsNullOrEmpty(imageInternalID)) { CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image"); r.CheckPoints.Add(cp_DeleteImage); XMLResult rt_DeleteImage = imageSvc.deleteImage(imageInternalID, new XMLParameter("preferences")); if (rt_DeleteImage.IsErrorOccured) { cp_DeleteImage.Result = TestResult.Fail; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message); } else { cp_DeleteImage.Result = TestResult.Pass; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message); } } #endregion CLEANUP: #region Step 11: Delete the patient used in this case if (!string.IsNullOrEmpty(patientInternalId)) { CheckPoint cp_DeletePatient = new CheckPoint("Step 11: Delete Patient", "Call patientService.deletePatient to delete the patient"); r.CheckPoints.Add(cp_DeletePatient); XMLResult rt_DeletePatient = PatientService.Utility_DeletePatientForSpecificCase(patientInternalId); if (rt_DeletePatient.IsErrorOccured) { cp_DeletePatient.Result = TestResult.Fail; cp_DeletePatient.Outputs.AddParameter("delete patient", "Delete patient returns error", rt_DeletePatient.Message); } else { cp_DeletePatient.Result = TestResult.Pass; cp_DeletePatient.Outputs.AddParameter("delete patient", "Delete patient returns success", rt_DeletePatient.Message); } } #endregion SaveRound(r); } catch (Exception ex) { CheckPoint cp = new CheckPoint(); r.CheckPoints.Add(cp); cp.Result = TestResult.Fail; cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.ToString()); SaveRound(r); } } Output(); }
//Case 1502: 1.9.3.1_deleteCrossSection_localizer_has_three_parents_and_delete_all_parents public void Run_3D_deleteCrossSection_deleteallparents_Case1502() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "delete_all_cs_shared_localizer"); CheckPoint pCreate = new CheckPoint("Workflow", "delete_all_cs_shared_localizer"); r.CheckPoints.Add(pCreate); CrossSectionService cs = new CrossSectionService(); XMLParameterCollection csInputData1 = new XMLParameterCollection(); XMLParameterCollection csInputData2 = new XMLParameterCollection(); XMLParameterCollection csInputData3 = new XMLParameterCollection(); XMLParameter cs1 = new XMLParameter("crosssection"); XMLParameter cs2 = new XMLParameter("crosssection"); XMLParameter cs3 = new XMLParameter("crosssection"); XMLParameter cs1_slicepath = new XMLParameter("slices_path_list"); XMLParameter cs2_slicepath = new XMLParameter("slices_path_list"); XMLParameter cs3_slicepath = new XMLParameter("slices_path_list"); XMLParameter cs1_slices_dicom_info_list = new XMLParameter("slices_dicom_info_list"); XMLParameter cs2_slices_dicom_info_list = new XMLParameter("slices_dicom_info_list"); XMLParameter cs3_slices_dicom_info_list = new XMLParameter("slices_dicom_info_list"); XMLParameter cs1_ps_xml_annotation_list = new XMLParameter("slices_ps_xml_annotation_list"); XMLParameter cs2_ps_xml_annotation_list = new XMLParameter("slices_ps_xml_annotation_list"); XMLParameter cs3_ps_xml_annotation_list = new XMLParameter("slices_ps_xml_annotation_list"); XMLParameter cs1_ps_xml_general_list = new XMLParameter("slices_ps_xml_general_list"); XMLParameter cs2_ps_xml_general_list = new XMLParameter("slices_ps_xml_general_list"); XMLParameter cs3_ps_xml_general_list = new XMLParameter("slices_ps_xml_general_list"); XMLParameter cs1_ps_xml_processing_list = new XMLParameter("slices_ps_xml_processing_list"); XMLParameter cs2_ps_xml_processing_list = new XMLParameter("slices_ps_xml_processing_list"); XMLParameter cs3_ps_xml_processing_list = new XMLParameter("slices_ps_xml_processing_list"); string volume1 = string.Empty; string volume2 = string.Empty; string volume3 = string.Empty; for (int i = 0; i < ids.InputParameters.Count; i++) { switch (ids.InputParameters.GetParameter(i).Step) { case "volume1": volume1 = ids.InputParameters.GetParameter(i).Value; break; case "createcs_crosssection": cs1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs3.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs_slices_dicom_info_list": cs1_slices_dicom_info_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs2_slices_dicom_info_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs3_slices_dicom_info_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs_slices_ps_xml_annotation_list": cs1_ps_xml_annotation_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs2_ps_xml_annotation_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs3_ps_xml_annotation_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs_slices_ps_xml_general_list": cs1_ps_xml_general_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs2_ps_xml_general_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs3_ps_xml_general_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs_slices_ps_xml_processing_list": cs1_ps_xml_processing_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs2_ps_xml_processing_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); cs3_ps_xml_processing_list.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs1_crosssection": cs1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs2_crosssection": cs2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs3_crosssection": cs3.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs1_slices_path_list": cs1_slicepath.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs2_slices_path_list": cs2_slicepath.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; case "createcs3_slices_path_list": cs3_slicepath.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value, false); break; } } csInputData1.Add(cs1); csInputData1.Add(cs1_slicepath); csInputData1.Add(cs1_slices_dicom_info_list); csInputData1.Add(cs1_ps_xml_annotation_list); csInputData1.Add(cs1_ps_xml_general_list); csInputData1.Add(cs1_ps_xml_processing_list); csInputData2.Add(cs2); csInputData2.Add(cs2_slicepath); csInputData2.Add(cs2_slices_dicom_info_list); csInputData2.Add(cs2_ps_xml_annotation_list); csInputData2.Add(cs2_ps_xml_general_list); csInputData2.Add(cs2_ps_xml_processing_list); csInputData3.Add(cs3); csInputData3.Add(cs3_slicepath); csInputData3.Add(cs3_slices_dicom_info_list); csInputData3.Add(cs3_ps_xml_annotation_list); csInputData3.Add(cs3_ps_xml_general_list); csInputData3.Add(cs3_ps_xml_processing_list); string test = csInputData1.GenerateXML(); XMLResult rslCreate1 = cs.createCrossSection(volume1, csInputData1); XMLResult rslCreate2 = cs.createCrossSection(volume1, csInputData2); XMLResult rslCreate3 = cs.createCrossSection(volume1, csInputData3); string csid1 = rslCreate1.SingleResult; string csid2 = rslCreate2.SingleResult; string csid3 = rslCreate3.SingleResult; XMLResult rslList = cs.listImagesOfCrossSection(csid1); string first_localizer = rslList.SingleResult; XMLResult rslDelete1 = cs.deleteCrossSection(csid1); XMLResult rslDelete2 = cs.deleteCrossSection(csid2); XMLResult rslDelete3 = cs.deleteCrossSection(csid3); ImageService imgsvr = new ImageService(); XMLParameter cInputImage = new XMLParameter("image"); cInputImage.AddParameter("internal_id", first_localizer); XMLResult rslget = imgsvr.getImageInfo(cInputImage); if (!rslCreate1.IsErrorOccured && !rslCreate2.IsErrorOccured && !rslCreate3.IsErrorOccured && !rslDelete1.IsErrorOccured && !rslDelete2.IsErrorOccured && !rslDelete3.IsErrorOccured && rslget.Code == 1006) { pCreate.Result = TestResult.Pass; pCreate.Outputs.AddParameter("Workflow", "delete all crosssection shared localizer", "OK"); } else { pCreate.Result = TestResult.Fail; string msg = "Create:" + rslCreate1.Message + "," + rslCreate2.Message + "," + rslCreate3.Message + ".Delete:" + rslDelete1.Message + rslDelete2.Message + rslDelete3.Message + ". GetImageCode:" + rslget.Code; pCreate.Outputs.AddParameter("Workflow", "delete all crosssection shared localizer", msg); } SaveRound(r); Output(); } }
//Case 101: 1.3.6_DeleteImage_Exception public void Run_Image_Delete_Exception_Case101() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; string imageUID = null; Round r = this.NewRound(runCount.ToString(), "Delete image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Key == "imageID") { imageUID = ids.InputParameters.GetParameter(i).Value; } } string epErrorCode = string.Empty; string epErrorMessage = string.Empty; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "delete") { if (ids.ExpectedValues.GetParameter(i).Key == "error_code") { epErrorCode = ids.ExpectedValues.GetParameter(i).Value; } else if (ids.ExpectedValues.GetParameter(i).Key == "error_message") { epErrorMessage = ids.ExpectedValues.GetParameter(i).Value; } } } try { ImageService imageSvc = new ImageService(); CheckPoint cpDeleteImage = new CheckPoint("Delete Image", "Test delete image exception cases"); r.CheckPoints.Add(cpDeleteImage); XMLParameter deletePreference = new XMLParameter("preferences"); deletePreference.AddParameter("completedFlag", "true"); XMLResult rtDeleteImage = imageSvc.deleteImage(imageUID, deletePreference); if (rtDeleteImage.IsErrorOccured) { if (rtDeleteImage.Code.ToString().Equals(epErrorCode) && rtDeleteImage.Message.Contains(epErrorMessage)) { cpDeleteImage.Result = TestResult.Pass; cpDeleteImage.Outputs.AddParameter("Delete image returns correct error message as expected", "Delete Image", rtDeleteImage.ResultContent); } else { cpDeleteImage.Result = TestResult.Fail; cpDeleteImage.Outputs.AddParameter("Delete image doesn't return correct error info as expected", "Delete Image", rtDeleteImage.ResultContent); } } else { cpDeleteImage.Result = TestResult.Pass; cpDeleteImage.Outputs.AddParameter("Delete image doesn't return error as expected", "Delete", rtDeleteImage.ResultContent); } 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 1091: 1.3.7_WorkFlow_AcquireRVG+SetImageInfo+GetPresentationStateInfo_RadioLogInformation public void Run_PS_Acq_Radiolog_Case1091() { //int runCount = this.Input.Repetition; int runCount = 0; // this is the initial run count. Use this count to repeat different test data set. foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Test round"); //Mark the check point here to indicate what's the check point here CheckPoint p1 = new CheckPoint("createPatient", "Setup environment of createPatient"); CheckPoint p2 = new CheckPoint("startAcquisition", "Setup environment of acquisition"); CheckPoint p3 = new CheckPoint("getAcquisitionResult", "Setup environment of image and PS id"); CheckPoint p4 = new CheckPoint("setImageInfo", "Setup environment of setImageInfo"); CheckPoint p5 = new CheckPoint("getImageInfo", "Test getImageInfo"); CheckPoint p6 = new CheckPoint("getPresentationStateInfo", "Test getPresentationStateInfo"); r.CheckPoints.Add(p1); r.CheckPoints.Add(p2); r.CheckPoints.Add(p3); r.CheckPoints.Add(p4); r.CheckPoints.Add(p5); r.CheckPoints.Add(p6); //create required PAS service instaces here PatientService pats = new PatientService(); AcquisitionService acq = new AcquisitionService(); ImageService img = new ImageService(); PresentationStateService ps = new PresentationStateService(); //create input parameters here, it may include XML path type and string type value XMLParameter pa1 = new XMLParameter("patient"); XMLParameter pa2 = new XMLParameter("acq_info"); XMLParameter pa3 = new XMLParameter("getAcquisitionResult"); XMLParameter pa4 = new XMLParameter("image"); XMLParameter pa5 = new XMLParameter("image"); XMLParameter pt6 = new XMLParameter("presentationstate"); XMLParameterCollection pa6 = new XMLParameterCollection(); try { for (int i = 0; i < ids.InputParameters.Count; i++) { switch (ids.InputParameters.GetParameter(i).Step) { case "createPatient": pa1.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); break; case "acquire": pa2.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); break; case "setImageInfo": pa4.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); break; default: Console.WriteLine("There is no valid selection when parse input parameters."); break; } } //If we need change parameter by specific logic, please put code here //Get service result //Step1 result XMLResult step1_result = pats.createPatient(pa1); //Log step1 service output if (step1_result.IsErrorOccured) { p1.Result = TestResult.Fail; p1.Outputs.AddParameter("createPatient", "Error", step1_result.ResultContent); SaveRound(r); continue; } p1.Result = TestResult.Pass; p1.Outputs.AddParameter("createPatient", "Success", step1_result.ResultContent); //Change input parameter according the output of Step1 pa2.AddParameter("patient_internal_id", step1_result.SingleResult); //Step2 result //if acquireType isn't emtpy string, skip step2, here is only RVG acquisition bool acqflag = true; XMLResult step3_result = new XMLResult(); if (pa2.GetParameterValueByName("acquireType") == null || pa2.GetParameterValueByName("acquireType") == "") { XMLResult rslAcqRVG = acq.startAcquisition(pa2); System.Threading.Thread.Sleep(3000); if (rslAcqRVG.IsErrorOccured) { System.Diagnostics.Debug.Print("Acquire fail:"); p2.Result = TestResult.Fail; p2.Outputs.AddParameter("acquire", "Acquire image error", rslAcqRVG.Message); } else { p2.Result = TestResult.Pass; p2.Outputs.AddParameter("acquire", "Acquire session ID", rslAcqRVG.SingleResult); int DORVGcount = 0; do { System.Threading.Thread.Sleep(3000); System.Diagnostics.Debug.Print("get acquire in do"); DORVGcount++; step3_result = acq.getAcquisitionResult(rslAcqRVG.SingleResult); if (!step3_result.IsErrorOccured) { // move this to out of do-while loop as need check the return value is correct or not there //p3.Result = TestResult.Pass; //p3.Outputs.AddParameter("acquire", "Get acquire image", step3_result.Message); acqflag = false; break; } if (step3_result.Code != 501) { continue; } else { p3.Result = TestResult.Fail; p3.Outputs.AddParameter("acquire", "Get acquire image error", step3_result.Message); acqflag = false; } System.Diagnostics.Debug.Print("get acquireResult:" + DORVGcount); if (DORVGcount > 60) { p3.Result = TestResult.Fail; p3.Outputs.AddParameter("acquire", "Get acquire image error", "Acquire greate with 3 minutes, timeout!"); acqflag = false; break; } } while (acqflag); } } //Change input parameter according the output of Step3 // if step3 is skipped, step4,step5,setp6 input has no need parameter of internal_id //2012-11-28/19006723: Chanege as ther getAcquisitionResult result change, need new way to get the image ID and PS ID string imgInternalID = string.Empty; string psInternalID = string.Empty; ParseXMLContent parser = new ParseXMLContent(step3_result.ResultContent); // To parse the return XML string imageID = parser.getStringWithPathAndType("trophy/object_info", "image", "value"); string[] imageIDs = imageID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int imageCount = imageIDs.Length; string psID = parser.getStringWithPathAndType("trophy/object_info", "presentation_state", "value"); string[] psIDs = psID.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int psCount = psIDs.Length; if (imageCount == 1 && psCount == 1) { p3.Result = TestResult.Pass; p3.Outputs.AddParameter("acquire", "getAcquisitionResult return OK", step3_result.ResultContent); imgInternalID = imageIDs[0]; psInternalID = psIDs[0]; pa5.AddParameter("internal_id", imgInternalID); pt6.AddParameter("internal_id", psInternalID); } else { p3.Result = TestResult.Fail; p3.Outputs.AddParameter("acquire", "getAcquisitionResult return ERROR", step3_result.ResultContent); SaveRound(r); continue; // Not run below steps } //if (step3_result.MultiResults.Count > 0) //{ // for (int j = 0; j < step3_result.MultiResults.Count; j++) // { // for (int i = 0; i < step3_result.MultiResults[j].Parameters.Count; i++) // { // if (step3_result.MultiResults[j].Parameters[i].ParameterName == "image_internal_id") // { // imgInternalID = step3_result.MultiResults[j].Parameters[i].ParameterValue; // pa5.AddParameter("internal_id", step3_result.MultiResults[j].Parameters[i].ParameterValue); // } // if (step3_result.MultiResults[j].Parameters[i].ParameterName == "presentation_state_internal_id") // { // pt6.AddParameter("internal_id", step3_result.MultiResults[j].Parameters[i].ParameterValue); // } // } // } //} //Step4 result XMLResult step4_result = img.setImageInfo(pa4, imgInternalID); //Log step4 service output if (step4_result.IsErrorOccured) { p4.Result = TestResult.Fail; p4.Outputs.AddParameter("setImageInfo", "Error", step4_result.ResultContent); SaveRound(r); continue; } p4.Result = TestResult.Pass; p4.Outputs.AddParameter("setImageInfo", "Success", step4_result.ResultContent); //Step5 result XMLResult step5_result = img.getImageInfo(pa5); //Log step3 service output //Compare the Expected parameters of getImageInfo and output result of getImageInfo //count of compare matched parameters int compCount = 0; //count of expected parameters on getImageInfo int expectedParameterCount = 0; for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++) { if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo") { expectedParameterCount++; } } for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++) { if (ids.ExpectedValues.Parameters[index].Step == "getImageInfo" && ids.ExpectedValues.Parameters[index].Value == step5_result.DicomArrayResult.GetParameterValueByName(ids.ExpectedValues.Parameters[index].Key)) { compCount++; } } if (step5_result.IsErrorOccured || compCount != expectedParameterCount) { p5.Result = TestResult.Fail; p5.Outputs.AddParameter("getImageInfo", "Error", step5_result.ResultContent); SaveRound(r); continue; } p5.Result = TestResult.Pass; p5.Outputs.AddParameter("getImageInfo", "Success", step5_result.ResultContent); //Change input parameter according the output of Step6 //generate input parameter collection of step6 pa6.Add(pt6); //Step6 result XMLResult step6_result = ps.getPresentationStateInfo(pa6); //Log step6 service output //Compare the Expected parameters of getPresentationStateInfo and output result of getPresentationStateInfo compCount = 0; //count of expected parameters on getPresentationStateInfo expectedParameterCount = 0; for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++) { if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo") { expectedParameterCount++; } } for (int index = 0; index < ids.ExpectedValues.Parameters.Count; index++) { if (ids.ExpectedValues.Parameters[index].Step == "getPresentationStateInfo" && ids.ExpectedValues.Parameters[index].Value == step6_result.DicomArrayResult.GetParameterValueByName(ids.ExpectedValues.Parameters[index].Key)) { compCount++; } } if (step6_result.IsErrorOccured || compCount != expectedParameterCount) { p6.Result = TestResult.Fail; p6.Outputs.AddParameter("getPresentationStateInfo", "Error", step6_result.ResultContent); } else { p6.Result = TestResult.Pass; p6.Outputs.AddParameter("getPresentationStateInfo", "Success", step6_result.ResultContent); } //Save data for each round SaveRound(r); } catch (Exception ex) { CheckPoint p = new CheckPoint("Excepption", "Exception thrown when case run: "+ex.ToString()); r.CheckPoints.Add(p); SaveRound(r); } } //Save service log as xml file Output(); }
// Case 1562: 1.1.04.05 SetImage_WorkFlow_02_Call setImage when archive path is NOT accessible and then call again when its accessible public void Run_Image_SetInfo_WorkFlow_Case1562() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { #region Parameter initialize string patientInternalId = string.Empty; string objectFileFullPath = string.Empty; string archivedPath = string.Empty; XMLParameter pSetImageInfo = new XMLParameter("image"); XMLParameter pSetImageInfoWithError = new XMLParameter("image"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "importImage") { if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id") { patientInternalId = ids.InputParameters.GetParameter(i).Value; } else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath") { objectFileFullPath = ids.InputParameters.GetParameter(i).Value; } else if (ids.InputParameters.GetParameter(i).Key == "archivePath") { archivedPath = ids.InputParameters.GetParameter(i).Value; } } else if (ids.InputParameters.GetParameter(i).Step == "setImageInfo_error") { pSetImageInfoWithError.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } else if (ids.InputParameters.GetParameter(i).Step == "setImageInfo_correct") { pSetImageInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } #endregion #region Step 1: Call ImportService.importObject to import a image string imageInternalID = string.Empty; string currentPSID = string.Empty; ImportService importService = new ImportService(); CheckPoint cpImportImage = new CheckPoint("Import Image", "Call ImportService.importObject to import an archived image"); r.CheckPoints.Add(cpImportImage); XMLResult rtImportImage = importService.importObject(patientInternalId, null, objectFileFullPath, archivedPath, true, "false"); if (rtImportImage.IsErrorOccured) { cpImportImage.Result = TestResult.Fail; cpImportImage.Outputs.AddParameter("Import image returns error", "Import image", rtImportImage.Message); SaveRound(r); continue; // There is error when create image, end current run } else { cpImportImage.Result = TestResult.Pass; cpImportImage.Outputs.AddParameter("Import image returns success", "Import image", rtImportImage.Message); imageInternalID = rtImportImage.MultiResults[0].Parameters[0].ParameterValue; currentPSID = rtImportImage.MultiResults[1].Parameters[0].ParameterValue; } #endregion ImageService imageService = new ImageService(); #region Step 2-1: Check the getImageDescription return is correct after import image CheckPoint cpGetImageDescriptionAfterImport = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after import image"); r.CheckPoints.Add(cpGetImageDescriptionAfterImport); XMLResult rtGetImageDescriptionAfterImport = imageService.getImageDescription(imageInternalID); string imagePathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("path"); string archivedPathAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("archive_path"); string archiveTagAfterImport = rtGetImageDescriptionAfterImport.MultiResults[0].GetParameterValueByName("tags"); if (imagePathAfterImport == string.Empty && archivedPathAfterImport == archivedPath && string.IsNullOrEmpty(archiveTagAfterImport)) { cpGetImageDescriptionAfterImport.Result = TestResult.Pass; cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after import image"); } else { cpGetImageDescriptionAfterImport.Result = TestResult.Fail; cpGetImageDescriptionAfterImport.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after import image. Actually get: " + rtGetImageDescriptionAfterImport.ResultContent); } #endregion #region Step 2-2: Check the info is correct in getImageInfo return after import image CheckPoint cpGetImageInfoAfterImport = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not import the image"); r.CheckPoints.Add(cpGetImageInfoAfterImport); XMLParameter pGetImageInfoAfterImport = new XMLParameter("image"); pGetImageInfoAfterImport.AddParameter("internal_id", imageInternalID); XMLResult rtGetImageInfo = imageService.getImageInfo(pGetImageInfoAfterImport); imagePathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("path"); archivedPathAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("archive_path"); archiveTagAfterImport = rtGetImageInfo.DicomArrayResult.GetParameterValueByName("tags"); if (string.IsNullOrEmpty(imagePathAfterImport) && string.IsNullOrEmpty(archivedPathAfterImport) && string.IsNullOrEmpty(archiveTagAfterImport)) // archivedPathAfterImport == archivedPath, will be supported in new service { cpGetImageInfoAfterImport.Result = TestResult.Pass; cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after import image"); } else { cpGetImageInfoAfterImport.Result = TestResult.Fail; cpGetImageInfoAfterImport.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after import image. Actually get: " + rtGetImageInfo.ResultContent); } #endregion #region Step 3-1: Call imageService.SetImageInfo to save the archived image but the archive path is wrong CheckPoint cpSetImageInfowithError = new CheckPoint("Set Image Info", "Call ImageService.SetImageInfo to save the archived image as normal image, with wrong path"); r.CheckPoints.Add(cpSetImageInfowithError); XMLResult rtSetImageInfowithError = imageService.setImageInfo(pSetImageInfoWithError, imageInternalID); if (rtSetImageInfowithError.IsErrorOccured) { cpSetImageInfowithError.Result = TestResult.Pass; cpSetImageInfowithError.Outputs.AddParameter("SetImageInfo returns error as expected", "SetImageInfo", rtSetImageInfowithError.Message); } else { cpSetImageInfowithError.Result = TestResult.Fail; cpSetImageInfowithError.Outputs.AddParameter("SetImageInfo returns success unexpectly", "SetImageInfo", rtSetImageInfowithError.Message); } #endregion System.Threading.Thread.Sleep(1000); #region Step 3-2: Call ImageService.SetImageInfo to save the archived image as normal image again CheckPoint cpSetImageInfo = new CheckPoint("Set Image Info", "Call ImageService.SetImageInfo to save the archived image as normal image again, with correct path"); r.CheckPoints.Add(cpSetImageInfo); XMLResult rtSetImageInfo = imageService.setImageInfo(pSetImageInfo, imageInternalID); if (rtSetImageInfo.IsErrorOccured) { cpSetImageInfo.Result = TestResult.Fail; cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns error", "SetImageInfo", rtSetImageInfo.Message); } else { cpSetImageInfo.Result = TestResult.Pass; cpSetImageInfo.Outputs.AddParameter("SetImageInfo returns success", "SetImageInfo", rtSetImageInfo.Message); // Wait the file is transferred to server DB System.Threading.Thread.Sleep(3000); // Below to check the info is correct after setImageInfo. Check points includes: //1. The Image ID and PS ID are not changed //2. GetImageDescription return correct image path and archive path, correct archive flag //3. GetImageInfo return correct image path, correct archive flag //4. Use the image path to check the image file is in server DB //5. The original archived image is not deleted #region Step 4: Check the ps is set, not newly created after set image CheckPoint cpPSID = new CheckPoint("Check PS ID", "Check the PS ID is not changed after call setImageInfo"); r.CheckPoints.Add(cpPSID); XMLParameter pListPS = new XMLParameter("filter"); pListPS.AddParameter("current", "true"); string currentPSIDAfterSet = imageService.listPresentationState(pListPS, imageInternalID).SingleResult; // may need change if (currentPSIDAfterSet == currentPSID) { cpPSID.Result = TestResult.Pass; cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is not changed"); } else { cpPSID.Result = TestResult.Fail; cpPSID.Outputs.AddParameter("listPresentationState", "Check PS ID", "The PS ID is changed. Expect: " + currentPSID + "; Actually new PS ID: " + currentPSIDAfterSet); } #endregion string imagePathAfterSet = string.Empty; string archivePathAfterSet = string.Empty; string archiveTagAfterSet = string.Empty; #region Step 5: Check the getImageDescription return is correct after set image CheckPoint cpGetImageDescriptionAfterSet = new CheckPoint("Check getImageDescription return", "Check getImageDescription return is corerct or not after call setImageInfo"); r.CheckPoints.Add(cpGetImageDescriptionAfterSet); XMLResult rtGetImageDescriptionAfterSet = imageService.getImageDescription(imageInternalID); imagePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("path"); archivePathAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("archive_path"); archiveTagAfterSet = rtGetImageDescriptionAfterSet.MultiResults[0].GetParameterValueByName("tags"); if (imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archiveTagAfterSet)) // imagePathAfterSet sample: C:/Documents and Settings/All Users/Application Data/TW/PAS/pas_data/patient/03/8af0a7e63310cc65013310d46d0e0003/1956bc28-ca5e-4720-a857-d4de18fc1479/02962f27-e4be-4d59-b112-9663a2f2572b.dcm" { cpGetImageDescriptionAfterSet.Result = TestResult.Pass; cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is correct after set image"); } else { cpGetImageDescriptionAfterSet.Result = TestResult.Fail; cpGetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Check getImageDescription return", "The getImageDescription return is not correct after set image. Actually get: " + rtGetImageDescriptionAfterSet.ResultContent); } #endregion #region Step 6: Check the getImageinfo return is correct after set image CheckPoint cpGetImageInfoAfterSet = new CheckPoint("Check getImageInfo return", "Check getImageInfo return is corerct or not after call setImageInfo"); r.CheckPoints.Add(cpGetImageInfoAfterSet); XMLParameter pGetImageInfoAfterSet = new XMLParameter("image"); pGetImageInfoAfterSet.AddParameter("internal_id", imageInternalID); XMLResult rtGetImageInfoAfterSet = imageService.getImageInfo(pGetImageInfoAfterSet); imagePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("path"); archivePathAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("archive_path"); archiveTagAfterSet = rtGetImageInfoAfterSet.DicomArrayResult.GetParameterValueByName("tags"); if (imagePathAfterSet.Contains(imageInternalID) && string.IsNullOrEmpty(archivePathAfterSet) && string.IsNullOrEmpty(archiveTagAfterSet)) { cpGetImageInfoAfterSet.Result = TestResult.Pass; cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is correct after set image"); } else { cpGetImageInfoAfterSet.Result = TestResult.Fail; cpGetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Check getImageInfo return", "The getImageInfo return is not correct after set image. Actually get: " + rtGetImageInfoAfterSet.ResultContent); } #endregion #region Step 7: Check the file exist in server DB CheckPoint cpImageInDB = new CheckPoint("Check file in DB", "Check the file exist in server DB after call setImageInfo"); r.CheckPoints.Add(cpImageInDB); if (Utility.IsImageExistInServerDB(imagePathAfterSet)) { cpImageInDB.Result = TestResult.Pass; cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File exist"); } else { cpImageInDB.Result = TestResult.Fail; cpImageInDB.Outputs.AddParameter("Check the file exist in server DB after call setImageInfo", "Check file in DB", "File NOT exist"); } #endregion #region Step 8: Check the original archived image is not deleted CheckPoint cpOriginalArchivedImage = new CheckPoint("Check original archived file", "Check the original archived image is not deleted after call setImageInfo"); r.CheckPoints.Add(cpOriginalArchivedImage); if (System.IO.File.Exists(archivedPath)) { cpOriginalArchivedImage.Result = TestResult.Pass; cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File exist"); } else { cpOriginalArchivedImage.Result = TestResult.Fail; cpOriginalArchivedImage.Outputs.AddParameter("Check the original archived image is not deleted after call setImageInfo", "Check original archived file", "File NOT exist"); } #endregion } #endregion #region Step 9: Call ImageService.deleteImage to delete the created image CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image"); r.CheckPoints.Add(cp_DeleteImage); XMLResult rt_DeleteImage = imageService.deleteImage(imageInternalID, new XMLParameter("preferences")); if (rt_DeleteImage.IsErrorOccured) { cp_DeleteImage.Result = TestResult.Fail; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message); } else { cp_DeleteImage.Result = TestResult.Pass; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message); } #endregion SaveRound(r); } catch (Exception ex) { CheckPoint cp = new CheckPoint(); r.CheckPoints.Add(cp); cp.Result = TestResult.Fail; cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message); SaveRound(r); } } Output(); }
//Case 10: 1.3.7_SetPresentationStateInfo_Normal public void Run_PS_SetPresentationStateInfo_Normal_Case10() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { #region Parameter initialize bool isImportImage = false; string psID = null; string imageID = null; //Input parameters string p_Import_patientId = null; string p_Import_objectFileFullPath = null; XMLParameter p_setPresentationStateInfo = new XMLParameter("presentationstate"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "import") { isImportImage = true; if (ids.InputParameters.GetParameter(i).Key == "patientInternalId") { p_Import_patientId = ids.InputParameters.GetParameter(i).Value; } else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath") { p_Import_objectFileFullPath = ids.InputParameters.GetParameter(i).Value; } } else if (ids.InputParameters.GetParameter(i).Step == "setPresentationStateInfo") { if (ids.InputParameters.GetParameter(i).Key == "presentationStateInternalID") { psID = ids.InputParameters.GetParameter(i).Value; } else { p_setPresentationStateInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } } // Output value bool ep_isSetPSInfoReturnOK = true; string ep_SetPSInfoReturnMessage = string.Empty; XMLParameter ep_getPresentationStateInfo = new XMLParameter(); for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "setPresentationStateInfo") { switch (ids.ExpectedValues.GetParameter(i).Key) { case "returnState": { if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("pass")) { ep_isSetPSInfoReturnOK = true; } else if (ids.ExpectedValues.GetParameter(i).Value.ToLower().Equals("fail")) { ep_isSetPSInfoReturnOK = false; } break; } case "returnMessage": { ep_SetPSInfoReturnMessage = ids.ExpectedValues.GetParameter(i).Value; break; } default: break; } } else if (ids.ExpectedValues.GetParameter(i).Step == "getPresentationStateInfo") { ep_getPresentationStateInfo.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } } #endregion ImportService importService = new ImportService(); PresentationStateService psService = new PresentationStateService(); if (isImportImage) { #region Step 1: Call ImportService.ImportObject to import an image and create a PS CheckPoint cp_Import = new CheckPoint("Import Image", "Call ImportService.ImportObject to import an image"); r.CheckPoints.Add(cp_Import); XMLResult rt_Import = importService.importObject(p_Import_patientId, null, p_Import_objectFileFullPath, null, true, "FALSE"); if (rt_Import.IsErrorOccured) { cp_Import.Result = TestResult.Fail; cp_Import.Outputs.AddParameter("import", "Import image returns error", rt_Import.Message); SaveRound(r); continue; // Error happens, end current Test Set } else { cp_Import.Result = TestResult.Pass; cp_Import.Outputs.AddParameter("import", "Import image returns success as expected", rt_Import.Message); imageID = rt_Import.MultiResults[0].Parameters[0].ParameterValue; // This one is the ImageID psID = rt_Import.MultiResults[1].Parameters[0].ParameterValue; // This one is the PS ID } #endregion } #region Step 2: Call PresentationStateService.SetPresentationStateInfo to set the PSInfo for the image CheckPoint cp_SetPresentationStateInfo = new CheckPoint("Set PSInfo", "Call PresentationStateService.SetPresentationStateInfo to set ps info"); r.CheckPoints.Add(cp_SetPresentationStateInfo); XMLResult rt_SetPresentationStateInfo = psService.setPresentationStateInfo(p_setPresentationStateInfo, psID); if (ep_isSetPSInfoReturnOK) // Expect the call return OK { if (rt_SetPresentationStateInfo.IsErrorOccured) { cp_SetPresentationStateInfo.Result = TestResult.Fail; cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns error", rt_SetPresentationStateInfo.Message); SaveRound(r); continue; // Error happens, end current Test Set } else { cp_SetPresentationStateInfo.Result = TestResult.Pass; cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns success as expected", rt_SetPresentationStateInfo.Message); #region Step 3: Call PresentationStateService.GetPresentationStateInfo to get the PSInfo for the image CheckPoint cp_GetPresentationStateInfo = new CheckPoint("Get PSInfo", "Call PresentationStateService.GetPresentationStateInfo and check the return state"); r.CheckPoints.Add(cp_GetPresentationStateInfo); XMLParameterCollection p_GetPresentationStateInfo = new XMLParameterCollection(); XMLParameter p_GetPSInfo_ID = new XMLParameter("presentationstate"); p_GetPSInfo_ID.AddParameter("internal_id", psID); // Add current psID as the input param XMLParameter p_GetPSInfo_Preferences = new XMLParameter("preferences"); p_GetPresentationStateInfo.Add(p_GetPSInfo_ID); p_GetPresentationStateInfo.Add(p_GetPSInfo_Preferences); XMLResult rt_GetPresentationStateInfo = psService.getPresentationStateInfo(p_GetPresentationStateInfo); if (rt_GetPresentationStateInfo.IsErrorOccured) { cp_GetPresentationStateInfo.Result = TestResult.Fail; cp_GetPresentationStateInfo.Outputs.AddParameter("state", "Get PSInfo returns error", rt_GetPresentationStateInfo.Message); SaveRound(r); continue; // Error happens, end current Test Get } else { cp_GetPresentationStateInfo.Result = TestResult.Pass; cp_GetPresentationStateInfo.Outputs.AddParameter("state", "Get PSInfo returns succeed", rt_GetPresentationStateInfo.Message); // Check the return value is correct #region Step 4: Check the values in PresentationStateService.getPresentationStateInfo return are correct CheckPoint cp_getPSInfoReturnValues = new CheckPoint("Get PSInfo", "Check the values in PresentationStateService.GetPresentationStateInfo return"); r.CheckPoints.Add(cp_getPSInfoReturnValues); // Add two check values dynamically ep_getPresentationStateInfo.AddParameter("internal_id", psID); ep_getPresentationStateInfo.AddParameter("image_internal_id", imageID); bool isValueEqual = false; bool isKeyShow = false; foreach (XMLParameterNode psNode in ep_getPresentationStateInfo.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < rt_GetPresentationStateInfo.DicomArrayResult.Parameters.Count; i++) { if (psNode.ParameterName == rt_GetPresentationStateInfo.DicomArrayResult.Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, rt_GetPresentationStateInfo.DicomArrayResult.Parameters[i].ParameterValue.Replace("\r", "").Replace("\n", "")); break; // Find the node, end current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { cp_getPSInfoReturnValues.Result = TestResult.Fail; if (isKeyShow) { System.Diagnostics.Debug.Print("The return value in getPresentationStateInfo does not match the expected."); cp_getPSInfoReturnValues.Outputs.AddParameter("PSInfo Info", "Check the values in PresentationStateService.getPresentationStateInfo return", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetPresentationStateInfo.MultiResults[0].Parameters[i].ParameterValue); } else { System.Diagnostics.Debug.Print("The return value in getPresentationStateInfo does not contain the node: " + psNode.ParameterName); cp_getPSInfoReturnValues.Outputs.AddParameter("PSInfo Info", "Check the values in PresentationStateService.getPresentationStateInfo return", "The return value does not contain the node: " + psNode.ParameterName); } break; // End current foreach loop, not compare the follwing nodes } } if (isValueEqual) { cp_getPSInfoReturnValues.Result = TestResult.Pass; System.Diagnostics.Debug.Print("The return values in getPresentationStateInfoInfo all match the expected."); cp_getPSInfoReturnValues.Outputs.AddParameter("PSInfo Info", "Check the values in PresentationStateService.getPresentationStateInfoInfo return", "The return values all match the expected"); } #endregion } #endregion } } else // Expect the call return error { if (rt_SetPresentationStateInfo.IsErrorOccured) // There is error { if (rt_SetPresentationStateInfo.Message.ToLower().Contains(ep_SetPSInfoReturnMessage.ToLower())) { cp_SetPresentationStateInfo.Result = TestResult.Pass; cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns error as expected", rt_SetPresentationStateInfo.Message); } else { cp_SetPresentationStateInfo.Result = TestResult.Fail; cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PresentationStateInfo returns error message not match the expected. ", "Expect: " + ep_SetPSInfoReturnMessage + "; Actually returns: " + rt_SetPresentationStateInfo.Message); SaveRound(r); continue; // Error happens, end current Test Get } } else // There is no error { cp_SetPresentationStateInfo.Result = TestResult.Fail; cp_SetPresentationStateInfo.Outputs.AddParameter("state", "Set PS not returns error as expected. ", "Actually returns: " + rt_SetPresentationStateInfo.Message); SaveRound(r); continue; // Error happens, end current Test Get } } #endregion if (isImportImage) { #region Step 5: Call ImageService.deleteImage to delete the created image ImageService imageService = new ImageService(); CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image"); r.CheckPoints.Add(cp_DeleteImage); XMLResult rt_DeleteImage = imageService.deleteImage(imageID, new XMLParameter("preferences")); if (rt_DeleteImage.IsErrorOccured) { cp_DeleteImage.Result = TestResult.Fail; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message); SaveRound(r); continue; // End current test set } else { cp_DeleteImage.Result = TestResult.Pass; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message); } #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 1178: 1.3.6_WorkFlow_N04_createImage_getImageInfo_getImageDescription_setImageInfo_getImageInfo_getImageDescription_deleteImage public void Run_Image_WorkFlow_Case1178() { int runCount = 0; string imageinternalUid = string.Empty; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Test Image Service: createImage -> getImageInfo & getImageDescription -> setImageInfo -> getImageInfo & getImageDescription -> deleteImage"); try { ImageService imageService = new ImageService(); #region Parameter Initialize XMLParameter p_CreateImage = new XMLParameter("image"); XMLParameter p_SetImageInfo = new XMLParameter("image"); //XMLParameter p_SetImage_series = new XMLParameter("series"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "createImage_image") { p_CreateImage.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "setImageInfo") { p_SetImageInfo.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } //if (ids.InputParameters.GetParameter(i).Step == "setImageInfo_series") //{ // p_SetImage_series.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); //} } XMLParameter ep_getImageInfoAfterCreate = new XMLParameter("image"); XMLParameter ep_getImageDescriptionAfterCreate = new XMLParameter("image"); //XMLParameter ep_getImageDescriptionAfterCreate_series = new XMLParameter("series"); XMLParameter ep_getImageInfoAfterSet = new XMLParameter("image"); XMLParameter ep_getImageDescriptionAfterSet = new XMLParameter("image"); //XMLParameter ep_getImageDescriptionAfterSet_series = new XMLParameter("series"); for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_AfterCreate") { ep_getImageInfoAfterCreate.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_AfterCreate") { ep_getImageDescriptionAfterCreate.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } //else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_AfterCreate_series") //{ // ep_getImageDescriptionAfterCreate_series.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); //} else if (ids.ExpectedValues.GetParameter(i).Step == "getImageInfo_AfterSet") { ep_getImageInfoAfterSet.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_AfterSet") { ep_getImageDescriptionAfterSet.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); } //else if (ids.ExpectedValues.GetParameter(i).Step == "getImageDescription_AfterSet_series") //{ // ep_getImageDescriptionAfterSet_series.AddParameter(ids.ExpectedValues.GetParameter(i).Key, ids.ExpectedValues.GetParameter(i).Value); //} } #endregion #region Step 1: Call ImageService.createImage to create a new image CheckPoint cp_CreateImage = new CheckPoint("Image create", "Call imageService.createImage to create a new image"); r.CheckPoints.Add(cp_CreateImage); XMLResult rt_CreateImage = imageService.createImage(p_CreateImage); if (rt_CreateImage.IsErrorOccured) { cp_CreateImage.Result = TestResult.Fail; cp_CreateImage.Outputs.AddParameter("create", "Create image returns error", rt_CreateImage.Message); SaveRound(r); break; // There is error, end test case } else { cp_CreateImage.Result = TestResult.Pass; cp_CreateImage.Outputs.AddParameter("create", "Create image returns success", rt_CreateImage.Message); imageinternalUid = rt_CreateImage.SingleResult; } #endregion #region Step 2: Call imageService.getImageInfo to check the return value CheckPoint cp_GetImageInfoAfterCreate = new CheckPoint("Get Image Info", "Call imageService.GetImageInfo to get Image Info after the image is created"); r.CheckPoints.Add(cp_GetImageInfoAfterCreate); XMLParameter p_GetImageInfoAfterCreate = new XMLParameter("image"); p_GetImageInfoAfterCreate.AddParameter("internal_id", imageinternalUid); XMLResult rt_GetImageInfoAfterCreate = imageService.getImageInfo(p_GetImageInfoAfterCreate); if (rt_GetImageInfoAfterCreate.IsErrorOccured) { cp_GetImageInfoAfterCreate.Result = TestResult.Fail; cp_GetImageInfoAfterCreate.Outputs.AddParameter("getImageInfo", "Get image info after create returns error", rt_GetImageInfoAfterCreate.Message); goto CLEANUP; } else { //Check the value bool isValueEqual = false; bool isKeyShow = false; foreach (XMLParameterNode psNode in ep_getImageInfoAfterCreate.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < rt_GetImageInfoAfterCreate.MultiResults[0].Parameters.Count; i++) { if (psNode.ParameterName == rt_GetImageInfoAfterCreate.MultiResults[0].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, rt_GetImageInfoAfterCreate.MultiResults[0].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { cp_GetImageInfoAfterCreate.Result = TestResult.Fail; if (isKeyShow) { System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected."); cp_GetImageInfoAfterCreate.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after create image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetImageInfoAfterCreate.MultiResults[0].Parameters[i].ParameterValue); } else { System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName); cp_GetImageInfoAfterCreate.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after create image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName); } break; // End current foreach loop, not compare the follwing nodes } } if (isValueEqual) { cp_GetImageInfoAfterCreate.Result = TestResult.Pass; System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected."); cp_GetImageInfoAfterCreate.Outputs.AddParameter("getImageInfo", "Get image info after create returns success", rt_GetImageInfoAfterCreate.Message); cp_GetImageInfoAfterCreate.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after create", "The return values in getImageInfo all match the expected"); } } #endregion #region Step 3: Call ImageService.getImageDescription to check the return value CheckPoint cp_GetImageDescriptionAfterCreate = new CheckPoint("Get Image Description", "Call Call imageService.GetImageDescription to get Image description after the image is created"); r.CheckPoints.Add(cp_GetImageDescriptionAfterCreate); XMLResult rt_GetImageDescriptionAfterCreate = imageService.getImageDescription(imageinternalUid); if (rt_GetImageDescriptionAfterCreate.IsErrorOccured) { cp_GetImageDescriptionAfterCreate.Result = TestResult.Fail; cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("getImageDescription", "Get image description after create returns error", rt_GetImageDescriptionAfterCreate.Message); goto CLEANUP; } else { //Check the value bool isValueEqual = false; bool isKeyShow = false; foreach (XMLParameterNode psNode in ep_getImageDescriptionAfterCreate.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < rt_GetImageDescriptionAfterCreate.MultiResults[0].Parameters.Count; i++) { if (psNode.ParameterName == rt_GetImageDescriptionAfterCreate.MultiResults[0].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, rt_GetImageDescriptionAfterCreate.MultiResults[0].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { cp_GetImageDescriptionAfterCreate.Result = TestResult.Fail; if (isKeyShow) { System.Diagnostics.Debug.Print("The return value in getImageDescription does not match the expected."); cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after create image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetImageDescriptionAfterCreate.MultiResults[0].Parameters[i].ParameterValue); } else { System.Diagnostics.Debug.Print("The return value in getImageDescription does not contain the node: " + psNode.ParameterName); cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after create image", "The return value in getImageDescription does not contain the node: " + psNode.ParameterName); } break; // End current foreach loop, not compare the follwing nodes } } if (isValueEqual) { cp_GetImageDescriptionAfterCreate.Result = TestResult.Pass; System.Diagnostics.Debug.Print("The return values in getImageDescription all match the expected."); cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("getImageDescription", "Get image Description after create returns success", rt_GetImageDescriptionAfterCreate.Message); cp_GetImageDescriptionAfterCreate.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after create", "The return values in getImageDescription all match the expected"); } } #endregion #region Step 4: Call imageService.setImageInfo to set image info CheckPoint cp_SetImageInfoAfterCreate = new CheckPoint("Set Image Info", "Call imageService.SetImageInfo to set Image Info after the image is created"); r.CheckPoints.Add(cp_SetImageInfoAfterCreate); XMLResult rt_SetImageInfoAfterCreate = imageService.setImageInfo(p_SetImageInfo, imageinternalUid); if (rt_SetImageInfoAfterCreate.IsErrorOccured) { cp_SetImageInfoAfterCreate.Result = TestResult.Fail; cp_SetImageInfoAfterCreate.Outputs.AddParameter("setImageInfo", "Set image info after create returns error", rt_SetImageInfoAfterCreate.Message); goto CLEANUP; } else { cp_SetImageInfoAfterCreate.Result = TestResult.Pass; cp_SetImageInfoAfterCreate.Outputs.AddParameter("setImageInfo", "Set image info after create returns success", rt_SetImageInfoAfterCreate.Message); } #endregion #region Step 5: Call imageService.getImageInfo to check the return value CheckPoint cp_GetImageInfoAfterSet = new CheckPoint("Get Image Info", "Call imageService.GetImageInfo to get Image Info after set the image info"); r.CheckPoints.Add(cp_GetImageInfoAfterSet); XMLParameter p_GetImageInfoAfterSet = new XMLParameter("image"); p_GetImageInfoAfterSet.AddParameter("internal_id", imageinternalUid); XMLResult rt_GetImageInfoAfterSet = imageService.getImageInfo(p_GetImageInfoAfterSet); if (rt_GetImageInfoAfterSet.IsErrorOccured) { cp_GetImageInfoAfterSet.Result = TestResult.Fail; cp_GetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Get image info after set returns error", rt_GetImageInfoAfterSet.Message); goto CLEANUP; } else { //Check the value bool isValueEqual = false; bool isKeyShow = false; foreach (XMLParameterNode psNode in ep_getImageInfoAfterSet.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < rt_GetImageInfoAfterSet.MultiResults[0].Parameters.Count; i++) { if (psNode.ParameterName == rt_GetImageInfoAfterSet.MultiResults[0].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, rt_GetImageInfoAfterSet.MultiResults[0].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { cp_GetImageInfoAfterSet.Result = TestResult.Fail; if (isKeyShow) { System.Diagnostics.Debug.Print("The return value in getImageInfo does not match the expected."); cp_GetImageInfoAfterSet.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after set image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetImageInfoAfterSet.MultiResults[0].Parameters[i].ParameterValue); } else { System.Diagnostics.Debug.Print("The return value in getImageInfo does not contain the node: " + psNode.ParameterName); cp_GetImageInfoAfterSet.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after set image", "The return value in getImageInfo does not contain the node: " + psNode.ParameterName); } break; // End current foreach loop, not compare the follwing nodes } } if (isValueEqual) { cp_GetImageInfoAfterSet.Result = TestResult.Pass; System.Diagnostics.Debug.Print("The return values in getImageInfo all match the expected."); cp_GetImageInfoAfterSet.Outputs.AddParameter("getImageInfo", "Get image info after set returns success", rt_GetImageInfoAfterSet.Message); cp_GetImageInfoAfterSet.Outputs.AddParameter("ImageInfo", "Check the values in getImageInfo return after set", "The return values in getImageInfo all match the expected"); } } #endregion #region Step 6: Call ImageService.getImageDescription to check the return value CheckPoint cp_GetImageDescriptionAfterSet = new CheckPoint("Get Image Description", "Call Call imageService.GetImageDescription to get Image description after the image is setd"); r.CheckPoints.Add(cp_GetImageDescriptionAfterSet); XMLResult rt_GetImageDescriptionAfterSet = imageService.getImageDescription(imageinternalUid); if (rt_GetImageDescriptionAfterSet.IsErrorOccured) { cp_GetImageDescriptionAfterSet.Result = TestResult.Fail; cp_GetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Get image description after set returns error", rt_GetImageDescriptionAfterSet.Message); goto CLEANUP; } else { //Check the value bool isValueEqual = false; bool isKeyShow = false; foreach (XMLParameterNode psNode in ep_getImageDescriptionAfterSet.Parameters) { isValueEqual = false; isKeyShow = false; int i = 0; for (i = 0; i < rt_GetImageDescriptionAfterSet.MultiResults[0].Parameters.Count; i++) { if (psNode.ParameterName == rt_GetImageDescriptionAfterSet.MultiResults[0].Parameters[i].ParameterName) { isKeyShow = true; isValueEqual = string.Equals(psNode.ParameterValue, rt_GetImageDescriptionAfterSet.MultiResults[0].Parameters[i].ParameterValue); break; // End current for loop to search node } } if (!isValueEqual) // There value is not matched or not found, log fail and then end the compare progress { cp_GetImageDescriptionAfterSet.Result = TestResult.Fail; if (isKeyShow) { System.Diagnostics.Debug.Print("The return value in getImageDescription does not match the expected."); cp_GetImageDescriptionAfterSet.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after set image", "The value does not match the expected for node: " + psNode.ParameterName + ". Expect: " + psNode.ParameterValue + ". Actually: " + rt_GetImageDescriptionAfterSet.MultiResults[0].Parameters[i].ParameterValue); } else { System.Diagnostics.Debug.Print("The return value in getImageDescription does not contain the node: " + psNode.ParameterName); cp_GetImageDescriptionAfterSet.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after set image", "The return value in getImageDescription does not contain the node: " + psNode.ParameterName); } break; // End current foreach loop, not compare the follwing nodes } } if (isValueEqual) { cp_GetImageDescriptionAfterSet.Result = TestResult.Pass; System.Diagnostics.Debug.Print("The return values in getImageDescription all match the expected."); cp_GetImageDescriptionAfterSet.Outputs.AddParameter("getImageDescription", "Get image Description after set returns success", rt_GetImageDescriptionAfterSet.Message); cp_GetImageDescriptionAfterSet.Outputs.AddParameter("ImageDescription", "Check the values in getImageDescription return after set", "The return values in getImageDescription all match the expected"); } } #endregion CLEANUP: #region Step 7: Call ImageService.deleteImage to delete the image CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image"); r.CheckPoints.Add(cp_DeleteImage); XMLResult rt_DeleteImage = imageService.deleteImage(imageinternalUid, new XMLParameter("preferences")); if (rt_DeleteImage.IsErrorOccured) { cp_DeleteImage.Result = TestResult.Fail; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message); SaveRound(r); break; // There is error, end test case } else { cp_DeleteImage.Result = TestResult.Pass; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message); } #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 1566: EK_HI00159159_Create Presentation State public void Run_PS_CreatePS_Case1566() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Test PresentationState Service: createPresentationState"); try { #region Parameter initialize string imageInternalID = string.Empty; string currentPSID = string.Empty; string patientInternalId = string.Empty; string objectFileFullPath = string.Empty; XMLParameter p_CreatePresentationState = new XMLParameter("presentationstate"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "importImage") { if (ids.InputParameters.GetParameter(i).Key == "patient_internal_id") { patientInternalId = ids.InputParameters.GetParameter(i).Value; } else if (ids.InputParameters.GetParameter(i).Key == "objectFileFullPath") { objectFileFullPath = ids.InputParameters.GetParameter(i).Value; } } else if (ids.InputParameters.GetParameter(i).Step == "createPresentationState") { p_CreatePresentationState.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } } bool ep_isCurrent = false; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Key == "isCurrent") { ep_isCurrent = ids.ExpectedValues.GetParameter(i).Value.Equals("true"); } } #endregion ImageService imageService = new ImageService(); ImportService importService = new ImportService(); PresentationStateService psService = new PresentationStateService(); #region Step 1: Call ImportService.importObject to import a image CheckPoint cp_ImportImage = new CheckPoint("Import Image", "Call ImportService.importObject to import a image"); r.CheckPoints.Add(cp_ImportImage); XMLResult rt_ImportImage = importService.importObject(patientInternalId, null, objectFileFullPath, null, true, "false"); if (rt_ImportImage.IsErrorOccured) { cp_ImportImage.Result = TestResult.Fail; cp_ImportImage.Outputs.AddParameter("Import", "Import image returns error", rt_ImportImage.Message); SaveRound(r); continue; // There is error when create image, end current run } else { cp_ImportImage.Result = TestResult.Pass; cp_ImportImage.Outputs.AddParameter("Import", "Import image returns success", rt_ImportImage.Message); imageInternalID = rt_ImportImage.MultiResults[0].Parameters[0].ParameterValue; currentPSID = rt_ImportImage.MultiResults[1].Parameters[0].ParameterValue; } #endregion #region Step 2: Call PresentationStateService.CreatePresentationState to create a PS for the image string returnPSID = string.Empty; CheckPoint cp_CreatePresentationState = new CheckPoint("Create PS", "Call PresentationStateService.CreatePresentationState to create a new ps"); r.CheckPoints.Add(cp_CreatePresentationState); XMLResult rt_CreatePresentationState = psService.createPresentationState(imageInternalID, p_CreatePresentationState); returnPSID = rt_CreatePresentationState.SingleResult; if (rt_CreatePresentationState.IsErrorOccured) { cp_CreatePresentationState.Result = TestResult.Fail; cp_CreatePresentationState.Outputs.AddParameter("create", "Create PS returns error", rt_CreatePresentationState.Message); } else { cp_CreatePresentationState.Result = TestResult.Pass; cp_CreatePresentationState.Outputs.AddParameter("create", "Create PS returns success", rt_CreatePresentationState.Message); CheckPoint cp_PresentationStateID = new CheckPoint("Check PS ID", "Check the retrun PS ID in create PS return"); r.CheckPoints.Add(cp_PresentationStateID); if (currentPSID == returnPSID) // Return the old current PS ID, defect EK_HI00159159 { cp_PresentationStateID.Result = TestResult.Fail; cp_PresentationStateID.Outputs.AddParameter("Check PS ID", "Create PS returns error", "The return ID is not new as expected after call createPS"); } else //Actually return a new PS ID { //Get new current PS ID XMLParameter pListPS = new XMLParameter("filter"); pListPS.AddParameter("current", "true"); currentPSID = imageService.listPresentationState(pListPS, imageInternalID).SingleResult; if (ep_isCurrent == (currentPSID == returnPSID)) { cp_PresentationStateID.Result = TestResult.Pass; cp_PresentationStateID.Outputs.AddParameter("Check PS ID", "Create PS returns error", "The PS ID is correct after call createPS"); } else { cp_PresentationStateID.Result = TestResult.Fail; cp_PresentationStateID.Outputs.AddParameter("Check PS ID", "Create PS returns error", "The PS ID is not correct after call createPS"); } } } #endregion #region Step 3: Call ImageService.deleteImage to delete the created image CheckPoint cp_DeleteImage = new CheckPoint("Delete Image", "Call imageService.deleteImage to delete the image"); r.CheckPoints.Add(cp_DeleteImage); XMLResult rt_DeleteImage = imageService.deleteImage(imageInternalID, new XMLParameter("preferences")); if (rt_DeleteImage.IsErrorOccured) { cp_DeleteImage.Result = TestResult.Fail; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns error", rt_DeleteImage.Message); } else { cp_DeleteImage.Result = TestResult.Pass; cp_DeleteImage.Outputs.AddParameter("delete image", "Delete image returns success", rt_DeleteImage.Message); } #endregion SaveRound(r); } catch (Exception ex) { CheckPoint cp = new CheckPoint(); r.CheckPoints.Add(cp); cp.Outputs.AddParameter("Exception thrown", "Exception Message", ex.Message); SaveRound(r); } } Output(); }
public void Run_Acquisition_GetImageInfo_Case1173() { int runCount = 0; string acquireType = string.Empty; ApplicationService app = new ApplicationService(); NotificationSim.ReceiveNotification rn = new NotificationSim.ReceiveNotification(); System.Collections.Generic.List<string> topics = new System.Collections.Generic.List<string>(); topics.Add("topic.acquisitionCompleted"); topics.Add("topic.imageCreated"); string stopTopic = "teststop"; string stopContent = "teststop"; rn.startListon(topics, stopTopic, stopContent); foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Acquisition"); AcquisitionService acqs = new AcquisitionService(); XMLParameter acq = new XMLParameter("acq_info"); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "acquire") { acq.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value); } if (ids.InputParameters.GetParameter(i).Step == "acquireType") { acquireType = ids.InputParameters.GetParameter(i).Key; } } CheckPoint pAcquire = new CheckPoint("Acquire Image", "Acquisition CR7600"); r.CheckPoints.Add(pAcquire); System.Diagnostics.Debug.Print("Acquire start"); XMLResult rslAcqRVG = acqs.startAcquisition(acq); System.Threading.Thread.Sleep(10000); switch (acquireType) { case "CR7600": System.Diagnostics.Debug.Print("CR7600 Acquire"); System.Diagnostics.Process p = System.Diagnostics.Process.Start("7600helper.exe"); p.WaitForExit(); break; default: System.Diagnostics.Debug.Print("NOT CR7600 Acquire"); break; } System.Threading.Thread.Sleep(60000);//Wait acqpanel exit app.sendGenericNotification(stopTopic, stopContent); System.Threading.Thread.Sleep(1000); if (rslAcqRVG.IsErrorOccured) { System.Diagnostics.Debug.Print("Acquire fail:"); pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Acquire image error", "startAcquisition", rslAcqRVG.Message); continue; } else { pAcquire.Outputs.AddParameter("Acquire session ID", "startAcquisition", rslAcqRVG.SingleResult); int msgnum = rn.getNotificationNumber(); if (msgnum != 3) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Notification Error", "startAcquisition", "RecievedMessageNo:" + msgnum.ToString() + ",Expected:3"); continue; } System.Collections.Generic.List<string> mmm = rn.getNotificationContent(); string[] token = mmm[0].Split('='); string imageid = token[token.Length - 1]; ImageService imgs = new ImageService(); XMLParameter cInputImgid = new XMLParameter("image"); cInputImgid.AddParameter("internal_id", imageid); XMLResult getRsl = imgs.getImageInfo(cInputImgid); if (!getRsl.IsErrorOccured) { pAcquire.Result = TestResult.Pass; pAcquire.Outputs.AddParameter("Acquistion Success", "startAcquisition", "Message:OK"); } else { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("GetImageInfo Error", "startAcquisition", "Message:" + getRsl.Message); continue; } } SaveRound(r); Output(); } }