public void Test_UploadContainerHandlingFinishReport_CREATE() { // prepare MyWebService1SoapClient ws = new MyWebService1SoapClient(); PSSApiAct act = new PSSApiAct() { Action = "CREATE", Tag = "" }; POP_HANDLING_FINISH_REPORT_CONTAINER formData = new POP_HANDLING_FINISH_REPORT_CONTAINER(); formData.VISA_NO = "VISA1234567890"; formData.APPLY_NO = "APPLY12345678"; POP_HANDLING_FINISH_REPORT_ITEMS_CONTAINER formItem = new POP_HANDLING_FINISH_REPORT_ITEMS_CONTAINER(); formItem.APPLY_NO = formData.APPLY_NO; List <POP_HANDLING_FINISH_REPORT_ITEMS_CONTAINER_SPECIAL> formItem2 = new List <POP_HANDLING_FINISH_REPORT_ITEMS_CONTAINER_SPECIAL>(); formItem2.Add(new POP_HANDLING_FINISH_REPORT_ITEMS_CONTAINER_SPECIAL() { APPLY_NO = formData.APPLY_NO, DW = 901, }); formItem2.Add(new POP_HANDLING_FINISH_REPORT_ITEMS_CONTAINER_SPECIAL() { APPLY_NO = formData.APPLY_NO, DW = 902, }); // GO PSSApiResponse returnMsg = ws.UploadContainerHandlingFinishReport( act, formData, formItem, formItem2.ToArray()); // expect result PSSApiResponse expectMsg = new PSSApiResponse() { processStatus = true, errorHappend = false, msg = "I_am_APPLY_NO", errorMsg = null }; // compare Assert.AreEqual(expectMsg.processStatus, returnMsg.processStatus); Assert.AreEqual(expectMsg.errorHappend, returnMsg.errorHappend); Assert.AreEqual(expectMsg.msg, returnMsg.msg); Assert.AreEqual(expectMsg.errorMsg, returnMsg.errorMsg); // 連資料庫驗證 IF EXISTS (SELECT * FROM POP_PORT_SERVICE WHERE APPLY_NO = apply_no ) //... }
public PSSApiResponse UploadContainerHandlingFinishReport(PSSApiAct act, POP_HANDLING_FINISH_REPORT_CONTAINER formData, POP_HANDLING_FINISH_REPORT_ITEMS_CONTAINER formItem, List <POP_HANDLING_FINISH_REPORT_ITEMS_CONTAINER_SPECIAL> formItem2) { // resource // PSSApiResponse respMsg = new PSSApiResponse(false, false, "ERROR", "預設失敗。"); // 前置檢查 if (String.IsNullOrWhiteSpace(formData.VISA_NO)) { return(new PSSApiResponse(false, true, "ERROR", "VISA_NO不可空白!")); } // GO try { switch (act.Action) { case "CREATE": //... break; case "MODIFY": //... break; default: // ERROR return(new PSSApiResponse(false, true, "ERROR", "觸發了預期之外的行為。")); //break; } // success return(new PSSApiResponse(true, false, "I_am_APPLY_NO", null)); } catch (Exception ex) { return(new PSSApiResponse(false, true, "EXCEPTION", ex.Message)); } finally { // release resource // ... } }