/// <summary> /// Validate length of required tokens that was present in the received ICOMS Message /// </summary> /// <param name="objdic"></param> /// <param name="str4LookUp"></param> /// <returns></returns> public string checkRequiredLengthOfTokens(Dictionary<string, string> objdic, ServiceListenerMembers templistenerMembers) { logger.Info("ServiceBusinessRulesManager::checkRequiredLengthOfTokens() called"); string strErrCode = string.Empty; string strSiteTokenName = templistenerMembers.siteIdTokenName; logger.Info(string.Format("ServiceBusinessRulesManager::checkRequiredLengthOfTokens :: siteId TokenName is {0}", strSiteTokenName)); foreach (KeyValuePair<string, string> pair in objdic) { using(ServiceTranslationManager trMgr=new ServiceTranslationManager()) { // Get relavent error code if any mismatch in token length logger.Info(string.Format("ServiceBusinessRulesManager::checkRequiredLengthOfTokens :: Checking length for token \"{0}\" ", pair.ToString())); if (pair.Key.Equals(strSiteTokenName))continue; strErrCode = trMgr.getErrorCode4lengthOfTokens(pair); if (strErrCode != string.Empty) { logger.Info("ServiceBusinessRulesManager::checkRequiredLengthOfTokens() failed"); return strErrCode; } } } logger.Info("ServiceBusinessRulesManager::checkRequiredLengthOfTokens() success"); return string.Empty; }
public void Test_getErrorCode4lengthOfTokens() { ServiceTranslationManager transMngr = new ServiceTranslationManager(); Assert.AreEqual("0000200", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("TI:", "0000000000000000000")), "Invalid Error code returned."); Assert.AreEqual("0000201", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("AN:", "0102030400")), "Invalid Error code returned."); Assert.AreEqual("0000202", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("SI:", "0130")), "Invalid Error code returned."); Assert.AreEqual("0000214", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("AS:", "A0")), "Invalid Error code returned."); Assert.AreEqual("0000216", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("CL:", "0000009950")), "Invalid Error code returned."); Assert.AreEqual("0000217", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("ES:", "A0")), "Invalid Error code returned."); Assert.AreEqual("0000219", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("EA:", "000029866859300000000000000000000")), "Invalid Error code returned."); Assert.AreEqual("0000221", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("AC:", "A0")), "Invalid Error code returned."); Assert.AreEqual("0000257", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("SV:", "000123")), "Invalid Error code returned."); }