//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(); }
//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 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 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 1122: 1.3.8_DeleteFMS_N2_Delete images from FMS public void Run_FMS_DeleteFMS_DeleteImageInFMS_Case1122() { 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(40, 300); 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) { XMLParameter delImagesFlag = new XMLParameter("preferences"); delImagesFlag.AddParameter("completedFlag", "true"); bool delImageSuccess = true; for (int i = 1; i <= imageCount; i++) { XMLResult delImageRls = igs.deleteImage(imageIDs[i - 1], delImagesFlag); if (delImageRls.IsErrorOccured) delImageSuccess = false; pAcquire.Outputs.AddParameter("Delete FMS Image: " + i, "Acquisition", delImageRls.ResultContent); } if (!delImageSuccess) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Delete FMS Images", "Acquisition", "Delete FMS Images Error"); break; } bool getImageFail = true; for (int i = 1; i <= imageCount; i++) { XMLResult getImageRls = igs.getImageDescription(imageIDs[i - 1]); if (!getImageRls.IsErrorOccured) getImageFail = false; pAcquire.Outputs.AddParameter("Get FMS Images: " + i, "Acquisition", getImageRls.ResultContent); } if (!getImageFail) { pAcquire.Result = TestResult.Fail; pAcquire.Outputs.AddParameter("Get FMS Images", "Acquisition", "Images do not delete from FMS"); break; } string FMSInternalID = fmsIDs[0]; 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 has been deleted"); break; } pAcquire.Outputs.AddParameter("Get FMS", "Acquisition", getFmsRls.ResultContent); pAcquire.Result = TestResult.Pass; pAcquire.Outputs.AddParameter("Delete FMS and images", "Acquisition", "FMS'images 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 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 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 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 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 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(); }