コード例 #1
0
        public void Test_PostAddressSearch_BySL_Success()
        {
            string strPLorSLNumber = "SL0000606479";

            RAL.SAPCallManager             objSAPCallManager           = new RAL.SAPCallManager(_strBaseUrl);
            Model.SAPAddressSearchResponse objSAPAddressSearchResponse = objSAPCallManager.GetAddressRecordsFromSAP(strPLorSLNumber);
            Assert.IsTrue(objSAPAddressSearchResponse != null);
            Assert.IsTrue(objSAPCallManager.ErrorMessages.Count == 0);

            Assert.IsTrue(objSAPAddressSearchResponse.ITAB.Length > 0);
            Assert.IsTrue(objSAPAddressSearchResponse.ITAB.Where(t => t.SORT2.ToUpper() == strPLorSLNumber.ToUpper()).Count() > 0);
            Assert.IsTrue(objSAPAddressSearchResponse.ITAB[0].ERROR == null);
            Assert.IsTrue(objSAPAddressSearchResponse.ITAB[0].MESSAGE == null);
        }
コード例 #2
0
        public void Test_PostAddressSearch_ByPL_NotFound()
        {
            string strPLorSLNumber = "PL0000000000";

            RAL.SAPCallManager             objSAPCallManager           = new RAL.SAPCallManager(_strBaseUrl);
            Model.SAPAddressSearchResponse objSAPAddressSearchResponse = objSAPCallManager.GetAddressRecordsFromSAP(strPLorSLNumber);
            Assert.IsTrue(objSAPAddressSearchResponse != null);
            Assert.IsTrue(objSAPCallManager.ErrorMessages.Count == 0);
            Assert.IsTrue(objSAPCallManager.HttpStatusCodeResult == System.Net.HttpStatusCode.NotFound);

            Assert.IsTrue(objSAPAddressSearchResponse.ITAB.Length == 1);
            Assert.IsTrue(objSAPAddressSearchResponse.ITAB[0].ERROR?.Length > 0);
            Assert.IsTrue(objSAPAddressSearchResponse.ITAB[0].MESSAGE?.Length > 0);
        }
        public static bool RecordFoundInSAP(Model.SAPAddressSearchResponse objSAPAddressSearchResponse, System.Net.HttpStatusCode objHttpStatusCode, string strPLOrSLNumber, out int intNumberOfValidRecords)
        {
            // Initialize the out param variable
            intNumberOfValidRecords = 0;

            try
            {
                // Check the http response code
                if (objHttpStatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    intNumberOfValidRecords = 0;
                    return(false);
                }

                // Check the response object to see if it is null
                if (objSAPAddressSearchResponse == null)
                {
                    intNumberOfValidRecords = 0;
                    return(false);
                }

                // Check the response object to see if the error property is populated
                if (objSAPAddressSearchResponse.ITAB.Where(t => t.ERROR?.Length > 0).Count() > 0)
                {
                    intNumberOfValidRecords = 0;
                    return(false);
                }

                // Set the number of valid records
                intNumberOfValidRecords = objSAPAddressSearchResponse.ITAB.Where(t => t.SORT2?.Trim().ToUpper() == strPLOrSLNumber?.Trim().ToUpper()).Count();

                return(intNumberOfValidRecords > 0);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("There was an exception while trying to analyze the response received from SAP, in an effort to determine if the record was actually found and how many times it appears in SAP with the corresponding PL or SL Number.  PLorSLNumber = [{0}], Error Message = [{1}].", strPLOrSLNumber, ex.Message));
            }
        }