public void Run_SimpleInstance_Create_Error_Case1589() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { SimpleInstanceServiceV2 simpleInstanceSvc = new SimpleInstanceServiceV2(); #region Input param SimpleCreateSimpleInstanceRequestType pCreate = new SimpleCreateSimpleInstanceRequestType(); pCreate.simpleInstance = new SimpleInstanceType(); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "createSimpleInstance") { switch (ids.InputParameters.GetParameter(i).Key) { case "patientUid": pCreate.simpleInstance.patientUid = ids.InputParameters.GetParameter(i).Value; break; case "filePath": pCreate.simpleInstance.filePath = ids.InputParameters.GetParameter(i).Value; break; default: break; } } } #endregion #region Expected Values string epCode = null; string epMessage = null; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "createSimpleInstance") { if (ids.ExpectedValues.GetParameter(i).Key == "code") { epCode = ids.ExpectedValues.GetParameter(i).Value; } else if (ids.ExpectedValues.GetParameter(i).Key == "message") { epMessage = ids.ExpectedValues.GetParameter(i).Value; } } } #endregion #region Step: Call create to create a normal simple instance CheckPoint cpCreate = new CheckPoint("Create", "Call create to create a normal simple instance"); r.CheckPoints.Add(cpCreate); SimpleCreateSimpleInstanceResponseType rtCreate = simpleInstanceSvc.createSimpleInstance(pCreate); if (!simpleInstanceSvc.LastReturnXMLValidateResult.isValid) { cpCreate.Result = TestResult.Fail; cpCreate.Outputs.AddParameter("Create Simple Instance", "XML Validation Result", "createSimpleInstance response is not complied with schema. Error:" + simpleInstanceSvc.LastReturnXMLValidateResult.message); cpCreate.Outputs.AddParameter("Create Simple Instance", "Return XML:", simpleInstanceSvc.LastReturnXML); SaveRound(r); continue; } else { if (rtCreate.status.code.ToString() == epCode && rtCreate.status.message.Contains(epMessage)) { cpCreate.Result = TestResult.Pass; cpCreate.Outputs.AddParameter("Create Simple Instance", "Return XML correct:", simpleInstanceSvc.LastReturnXML); } else { cpCreate.Result = TestResult.Fail; cpCreate.Outputs.AddParameter("Create Simple Instance", "Return XML wrong:", "Expect code: " + epCode + "; message: " + epMessage + ". Actually get: " + simpleInstanceSvc.LastReturnXML); SaveRound(r); continue; } } #endregion SaveRound(r); } catch (Exception ex) { CheckPoint cp = new CheckPoint(); r.CheckPoints.Add(cp); cp.Result = TestResult.Fail; cp.Outputs.AddParameter("Exception thrown when case runs", "Exception message", ex.Message); SaveRound(r); } } Output(); }
// Create archived public void Run_SimpleInstance_WorkFlow_Case1583() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), ids.Description); try { SimpleInstanceServiceV2 simpleInstanceSvc = new SimpleInstanceServiceV2(); #region Input param SimpleCreateSimpleInstanceRequestType pCreate = new SimpleCreateSimpleInstanceRequestType(); pCreate.simpleInstance = new SimpleInstanceType(); SimpleSetSimpleInstanceInfoRequestType pSet = new SimpleSetSimpleInstanceInfoRequestType(); pSet.simpleInstance = new SimpleInstanceType(); for (int i = 0; i < ids.InputParameters.Count; i++) { if (ids.InputParameters.GetParameter(i).Step == "createSimpleInstance") { switch (ids.InputParameters.GetParameter(i).Key) { case "patientUid": pCreate.simpleInstance.patientUid = ids.InputParameters.GetParameter(i).Value; break; case "archivePath": pCreate.simpleInstance.archivePath = ids.InputParameters.GetParameter(i).Value; break; case "originalPath": pCreate.simpleInstance.originalPath = ids.InputParameters.GetParameter(i).Value; break; case "instanceType": pCreate.simpleInstance.instanceType = ids.InputParameters.GetParameter(i).Value; break; case "comments": pCreate.simpleInstance.comments = ids.InputParameters.GetParameter(i).Value; break; case "sopInstanceUid": pCreate.simpleInstance.sopInstanceUid = ids.InputParameters.GetParameter(i).Value; break; default: break; } } } #endregion #region Expected Values SimpleGetSimpleInstanceResponseType epGet = new SimpleGetSimpleInstanceResponseType(); epGet.simpleInstance = new SimpleInstanceType(); SimpleGetSimpleInstanceInfoResponseType epGetInfo = new SimpleGetSimpleInstanceInfoResponseType(); epGetInfo.simpleInstance = new SimpleInstanceType(); epGetInfo.simpleInstance.filePath = null; for (int i = 0; i < ids.ExpectedValues.Count; i++) { if (ids.ExpectedValues.GetParameter(i).Step == "getSimpleInstance") { switch (ids.ExpectedValues.GetParameter(i).Key) { case "patientUid": epGet.simpleInstance.patientUid = ids.ExpectedValues.GetParameter(i).Value; break; case "archivePath": epGet.simpleInstance.archivePath = ids.ExpectedValues.GetParameter(i).Value; break; case "originalPath": epGet.simpleInstance.originalPath = ids.ExpectedValues.GetParameter(i).Value; break; case "instanceType": epGet.simpleInstance.instanceType = ids.ExpectedValues.GetParameter(i).Value; break; case "comments": epGet.simpleInstance.comments = ids.ExpectedValues.GetParameter(i).Value; break; case "sopInstanceUid": epGet.simpleInstance.sopInstanceUid = ids.ExpectedValues.GetParameter(i).Value; break; //case "fileCreatedTime": //When create, there is no file info returned as no given // epGet.simpleInstance.fileCreatedTime = ids.ExpectedValues.GetParameter(i).Value; // break; //case "fileModifiedTime": //When create, there is no file info returned as no given // epGet.simpleInstance.fileModifiedTime = ids.ExpectedValues.GetParameter(i).Value; // break; default: break; } } else if (ids.ExpectedValues.GetParameter(i).Step == "getSimpleInstanceInfo") { switch (ids.ExpectedValues.GetParameter(i).Key) { case "patientUid": epGetInfo.simpleInstance.patientUid = ids.ExpectedValues.GetParameter(i).Value; break; case "archivePath": epGetInfo.simpleInstance.archivePath = ids.ExpectedValues.GetParameter(i).Value; break; case "originalPath": epGetInfo.simpleInstance.originalPath = ids.ExpectedValues.GetParameter(i).Value; break; case "instanceType": epGetInfo.simpleInstance.instanceType = ids.ExpectedValues.GetParameter(i).Value; break; case "objectType": epGetInfo.simpleInstance.objectType = ids.ExpectedValues.GetParameter(i).Value; break; case "comments": epGetInfo.simpleInstance.comments = ids.ExpectedValues.GetParameter(i).Value; break; case "sopInstanceUid": epGetInfo.simpleInstance.sopInstanceUid = ids.ExpectedValues.GetParameter(i).Value; break; //case "fileCreatedTime": //When create, there is no file info returned // epGetInfo.simpleInstance.fileCreatedTime = ids.ExpectedValues.GetParameter(i).Value; // break; //case "fileModifiedTime": //When create, there is no file info returned // epGetInfo.simpleInstance.fileModifiedTime = ids.ExpectedValues.GetParameter(i).Value; // break; case "fileName": epGetInfo.simpleInstance.fileName = ids.ExpectedValues.GetParameter(i).Value; break; default: break; } } } #endregion #region Step: Call create to create a archive simple instance CheckPoint cpCreate = new CheckPoint("Create", "Call create to create a archive simple instance"); r.CheckPoints.Add(cpCreate); SimpleCreateSimpleInstanceResponseType rtCreate = simpleInstanceSvc.createSimpleInstance(pCreate); if (!simpleInstanceSvc.LastReturnXMLValidateResult.isValid) { cpCreate.Result = TestResult.Fail; cpCreate.Outputs.AddParameter("Create Simple Instance", "XML Validation Result", "createSimpleInstance response is not complied with schema. Error:" + simpleInstanceSvc.LastReturnXMLValidateResult.message); cpCreate.Outputs.AddParameter("Create Simple Instance", "Return XML:", simpleInstanceSvc.LastReturnXML); SaveRound(r); continue; } else { if (rtCreate.status.code == 0 && rtCreate.status.message == "ok") { cpCreate.Result = TestResult.Pass; cpCreate.Outputs.AddParameter("Create Simple Instance", "Return XML correct:", simpleInstanceSvc.LastReturnXML); } else { cpCreate.Result = TestResult.Fail; cpCreate.Outputs.AddParameter("Create Simple Instance", "Return XML wrong:", simpleInstanceSvc.LastReturnXML); SaveRound(r); continue; } } #endregion #region Step: Call get to the archive simple instance after create CheckPoint cpGetSimpleInstance = new CheckPoint("Get Simple Instance", "Get Simple Instance"); r.CheckPoints.Add(cpGetSimpleInstance); SimpleGetSimpleInstanceResponseType rtGetSimpleInstance = simpleInstanceSvc.getSimpleInstance(rtCreate.simpleInstance.uid); if (!simpleInstanceSvc.LastReturnXMLValidateResult.isValid) { cpGetSimpleInstance.Result = TestResult.Fail; cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Invalid XML", "GetSimpleInstance response is not complied with schema."); SaveRound(r); continue; } else { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Return XML", "getSimpleInstance returns result. " + simpleInstanceSvc.LastReturnXML); cpGetSimpleInstance.Result = TestResult.Pass; } if (rtGetSimpleInstance.status.code != 0 || rtGetSimpleInstance.status.message != "ok") { cpGetSimpleInstance.Result = TestResult.Fail; cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check the getSimpleInstance response", "getSimpleInstance doesn't return expected result. Code:" + rtGetSimpleInstance.status.code.ToString() + "; Message:" + rtGetSimpleInstance.status.message); SaveRound(r); continue; } // Check the return value if (rtGetSimpleInstance.simpleInstance.patientUid != epGet.simpleInstance.patientUid) { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check patientUid", "getSimpleInstance doesn't return expected patientUid." + "Expect: " + epGet.simpleInstance.patientUid + ". Get: " + rtGetSimpleInstance.simpleInstance.patientUid); cpGetSimpleInstance.Result = TestResult.Fail; } if (rtGetSimpleInstance.simpleInstance.filePath != null) { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check filePath", "getSimpleInstance doesn't return expected filePath. Expect null" + ". Get: " + rtGetSimpleInstance.simpleInstance.filePath); cpGetSimpleInstance.Result = TestResult.Fail; } if (rtGetSimpleInstance.simpleInstance.archivePath != epGet.simpleInstance.archivePath) { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check archivePath", "getSimpleInstance doesn't return expected archivePath. Expect: " + epGetInfo.simpleInstance.archivePath + ". Get: " + rtGetSimpleInstance.simpleInstance.archivePath); cpGetSimpleInstance.Result = TestResult.Fail; } if (rtGetSimpleInstance.simpleInstance.originalPath != epGet.simpleInstance.originalPath) { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check originalPath", "getSimpleInstance doesn't return expected originalPath." + "Expect: " + epGet.simpleInstance.originalPath + ". Get: " + rtGetSimpleInstance.simpleInstance.originalPath); cpGetSimpleInstance.Result = TestResult.Fail; } if (rtGetSimpleInstance.simpleInstance.sopInstanceUid != epGet.simpleInstance.sopInstanceUid) { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check sopInstanceUid", "getSimpleInstance doesn't return expected sopInstanceUid." + "Expect: " + epGet.simpleInstance.sopInstanceUid + ". Get: " + rtGetSimpleInstance.simpleInstance.sopInstanceUid); cpGetSimpleInstance.Result = TestResult.Fail; } if (rtGetSimpleInstance.simpleInstance.instanceType != epGet.simpleInstance.instanceType) { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check instanceType", "getSimpleInstance doesn't return expected instanceType." + "Expect: " + epGet.simpleInstance.instanceType + ". Get: " + rtGetSimpleInstance.simpleInstance.instanceType); cpGetSimpleInstance.Result = TestResult.Fail; } if (rtGetSimpleInstance.simpleInstance.comments != epGet.simpleInstance.comments) { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check comments", "getSimpleInstance doesn't return expected comments." + "Expect: " + epGet.simpleInstance.comments + ". Get: " + rtGetSimpleInstance.simpleInstance.comments); cpGetSimpleInstance.Result = TestResult.Fail; } if (!Utility.IsTimeEqualNow(rtGetSimpleInstance.simpleInstance.creationDateTime)) { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check creationDateTime", "getSimpleInstance doesn't return expected creationDateTime." + "Expect: " + epGet.simpleInstance.creationDateTime + ". Get: " + rtGetSimpleInstance.simpleInstance.creationDateTime); cpGetSimpleInstance.Result = TestResult.Fail; } if (!Utility.IsTimeEqualNow(rtGetSimpleInstance.simpleInstance.lastUpdateDateTime)) { cpGetSimpleInstance.Outputs.AddParameter("Get Simple Instance", "Check lastUpdateDateTime", "getSimpleInstance doesn't return expected lastUpdateDateTime." + "Expect: " + epGet.simpleInstance.lastUpdateDateTime + ". Get: " + rtGetSimpleInstance.simpleInstance.lastUpdateDateTime); cpGetSimpleInstance.Result = TestResult.Fail; } //To do: need add back //if (rtGetSimpleInstanceAfterCreate.simpleInstance.fileCreatedTime != epGetAfterCreate.simpleInstance.fileCreatedTime) //{ // cpGetSimpleInstanceAfterCreate.Outputs.AddParameter("Get Simple Instance", "Check fileCreatedTime", "getSimpleInstance doesn't return expected fileCreatedTime." + "Expect: " + epGetAfterCreate.simpleInstance.fileCreatedTime + ". Get: " + rtGetSimpleInstanceAfterCreate.simpleInstance.fileCreatedTime); // cpGetSimpleInstanceAfterCreate.Result = TestResult.Fail; //} //if (rtGetSimpleInstanceAfterCreate.simpleInstance.fileModifiedTime != epGetAfterCreate.simpleInstance.fileModifiedTime) //{ // cpGetSimpleInstanceAfterCreate.Outputs.AddParameter("Get Simple Instance", "Check fileModifiedTime", "getSimpleInstance doesn't return expected fileModifiedTime." + "Expect: " + epGetAfterCreate.simpleInstance.fileModifiedTime + ". Get: " + rtGetSimpleInstanceAfterCreate.simpleInstance.fileModifiedTime); // cpGetSimpleInstanceAfterCreate.Result = TestResult.Fail; //} #endregion #region Step: Call getInfo to a normal simple isntance after create CheckPoint cpGetSimpleInstanceInfo = new CheckPoint("Get Simple Instance Info", "Get Simple Instance Info"); r.CheckPoints.Add(cpGetSimpleInstanceInfo); SimpleGetSimpleInstanceInfoResponseType rtGetSimpleInstanceInfo = simpleInstanceSvc.getSimpleInstanceInfo(rtCreate.simpleInstance.uid); if (!simpleInstanceSvc.LastReturnXMLValidateResult.isValid) { cpGetSimpleInstanceInfo.Result = TestResult.Fail; cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Invalid XML", "GetSimpleInstanceInfo response is not complied with schema."); SaveRound(r); continue; } else { cpGetSimpleInstanceInfo.Result = TestResult.Pass; cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Return XML", "GetSimpleInstanceInfo returns result. " + simpleInstanceSvc.LastReturnXML); } if (rtGetSimpleInstanceInfo.status.code != 0 || rtGetSimpleInstanceInfo.status.message != "ok") { cpGetSimpleInstanceInfo.Result = TestResult.Fail; cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check the GetSimpleInstanceInfo response", "GetSimpleInstanceInfo doesn't return expected result. Code:" + rtGetSimpleInstanceInfo.status.code.ToString() + "; Message:" + rtGetSimpleInstanceInfo.status.message); SaveRound(r); continue; } // Check the return value if (rtGetSimpleInstanceInfo.simpleInstance.patientUid != epGetInfo.simpleInstance.patientUid) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check patientUid", "GetSimpleInstanceInfo doesn't return expected patientUid." + "Expect: " + epGetInfo.simpleInstance.patientUid + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.patientUid); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (rtGetSimpleInstanceInfo.simpleInstance.filePath != null) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check filePath", "GetSimpleInstanceInfo doesn't return expected filePath." + "Expect null " + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.filePath); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (rtGetSimpleInstanceInfo.simpleInstance.archivePath != epGetInfo.simpleInstance.archivePath) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check archivePath", "GetSimpleInstanceInfo doesn't return expected archivePath." + "Expect: " + epGetInfo.simpleInstance.archivePath + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.archivePath); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (rtGetSimpleInstanceInfo.simpleInstance.originalPath != epGetInfo.simpleInstance.originalPath) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check originalPath", "GetSimpleInstanceInfo doesn't return expected originalPath." + "Expect: " + epGetInfo.simpleInstance.originalPath + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.originalPath); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (rtGetSimpleInstanceInfo.simpleInstance.sopInstanceUid != epGetInfo.simpleInstance.sopInstanceUid) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check sopInstanceUid", "GetSimpleInstanceInfo doesn't return expected sopInstanceUid." + "Expect: " + epGetInfo.simpleInstance.sopInstanceUid + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.sopInstanceUid); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (rtGetSimpleInstanceInfo.simpleInstance.instanceType != epGetInfo.simpleInstance.instanceType) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check instanceType", "GetSimpleInstanceInfo doesn't return expected instanceType." + "Expect: " + epGetInfo.simpleInstance.instanceType + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.instanceType); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (rtGetSimpleInstanceInfo.simpleInstance.objectType != epGetInfo.simpleInstance.objectType) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check instanceType", "GetSimpleInstanceInfo doesn't return expected objectType." + "Expect: " + epGetInfo.simpleInstance.objectType + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.objectType); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (rtGetSimpleInstanceInfo.simpleInstance.comments != epGetInfo.simpleInstance.comments) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check comments", "GetSimpleInstanceInfo doesn't return expected comments." + "Expect: " + epGetInfo.simpleInstance.comments + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.comments); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (!Utility.IsTimeEqualNow(rtGetSimpleInstanceInfo.simpleInstance.creationDateTime)) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check creationDateTime", "GetSimpleInstanceInfo doesn't return expected creationDateTime." + "Expect: " + epGetInfo.simpleInstance.creationDateTime + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.creationDateTime); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (!Utility.IsTimeEqualNow(rtGetSimpleInstanceInfo.simpleInstance.lastUpdateDateTime)) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check lastUpdateDateTime", "GetSimpleInstanceInfo doesn't return expected lastUpdateDateTime." + "Expect: " + epGetInfo.simpleInstance.lastUpdateDateTime + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.lastUpdateDateTime); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } if (rtGetSimpleInstanceInfo.simpleInstance.fileName != epGetInfo.simpleInstance.fileName) { cpGetSimpleInstanceInfo.Outputs.AddParameter("Get Simple Instance Info", "Check fileName", "GetSimpleInstanceInfo doesn't return expected fileName." + "Expect: " + epGetInfo.simpleInstance.fileName + ". Get: " + rtGetSimpleInstanceInfo.simpleInstance.fileName); cpGetSimpleInstanceInfo.Result = TestResult.Fail; } //To do: need add back //if (rtGetSimpleInstanceInfoAfterCreate.simpleInstance.fileCreatedTime != epGetAfterCreate.simpleInstance.fileCreatedTime) //{ // cpGetSimpleInstanceInfoAfterCreate.Outputs.AddParameter("Get Simple Instance Info", "Check fileCreatedTime", "GetSimpleInstanceInfo doesn't return expected fileCreatedTime." + "Expect: " + epGetAfterCreate.simpleInstance.fileCreatedTime + ". Get: " + rtGetSimpleInstanceInfoAfterCreate.simpleInstance.fileCreatedTime); // cpGetSimpleInstanceInfoAfterCreate.Result = TestResult.Fail; //} //if (rtGetSimpleInstanceInfoAfterCreate.simpleInstance.fileModifiedTime != epGetAfterCreate.simpleInstance.fileModifiedTime) //{ // cpGetSimpleInstanceInfoAfterCreate.Outputs.AddParameter("Get Simple Instance Info", "Check fileModifiedTime", "GetSimpleInstanceInfo doesn't return expected fileModifiedTime." + "Expect: " + epGetAfterCreate.simpleInstance.fileModifiedTime + ". Get: " + rtGetSimpleInstanceInfoAfterCreate.simpleInstance.fileModifiedTime); // cpGetSimpleInstanceInfoAfterCreate.Result = TestResult.Fail; //} #endregion SaveRound(r); } catch (Exception ex) { CheckPoint cp = new CheckPoint(); r.CheckPoints.Add(cp); cp.Result = TestResult.Fail; cp.Outputs.AddParameter("Exception thrown when case runs", "Exception message", ex.Message); SaveRound(r); } } Output(); }