コード例 #1
0
        /// <summary>
        /// Mock complete session response depends on transaction type
        /// </summary>
        /// <param name="transactionType">Type of transation</param>
        /// <param name="mgiSessionId"></param>
        /// <param name="thermalReceipts">When true, thermal receipts will be returned</param>
        /// <returns>Mocked complete session response</returns>
        public CompleteSessionResponse MockCompleteSessionResponse(SessionType transactionType, string mgiSessionId, bool thermalReceipts)
        {
            Func <TrainingModeResponses, string> getFileName = null;

            switch (transactionType)
            {
            case SessionType.SEND:
                getFileName = thermalReceipts
                        ? (Func <TrainingModeResponses, string>)(r => r.SendCompleteSessionThermal)
                        : (r => r.SendCompleteSession);
                break;

            case SessionType.BP:
                getFileName = thermalReceipts
                        ? (Func <TrainingModeResponses, string>)(r => r.BillPayCompleteSessionThermal)
                        : (r => r.BillPayCompleteSession);
                break;

            case SessionType.RCV:
                getFileName = thermalReceipts
                        ? (Func <TrainingModeResponses, string>)(r => IsStagedTransaction(SessionType.RCV, mgiSessionId) ? r.StagedReceiveCompleteSessionThermal : r.ReceiveCompleteSessionThermal)
                        : (r => IsStagedTransaction(SessionType.RCV, mgiSessionId) ? r.StagedReceiveCompleteSession : r.ReceiveCompleteSession);
                break;

            case SessionType.AMD:
                getFileName = r => r.AmendCompleteSession;
                break;

            case SessionType.SREV:
                getFileName = r => r.SendReversalCompleteSession;
                break;
            }

            return(TrainingModeConfiguration.GetResponse <CompleteSessionResponse>(transactionType.ToTrainingModeSessionType(), mgiSessionId, getFileName));
        }
コード例 #2
0
        /// <summary>
        /// Mock transactionlookup response depends on reference number
        /// </summary>
        /// <param name="referenceNumber"></param>
        /// <param name="purposeOfLookup"></param>
        /// <returns></returns>
        public TransactionLookupResponse MockTransactionLookupResponse(string referenceNumber, string purposeOfLookup)
        {
            SessionType sessionType = SessionType.AMD;

            Func <TrainingModeResponses, string> getFileName = null;

            TransactionLookupResponse response = null;

            switch (purposeOfLookup)
            {
            case PurposeOfLookup.Receive:
                sessionType = SessionType.RCV;
                getFileName = x => x.ReceiveTransactionLookup;
                break;

            case PurposeOfLookup.ReceiveCompletion:
                sessionType = SessionType.RCV;
                getFileName = x => x.StagedReceiveTransactionLookup;
                break;

            case PurposeOfLookup.SendCompletion:
                sessionType = SessionType.SEND;
                getFileName = x => x.StagedSendTransactionLookup;
                break;

            case PurposeOfLookup.BillPayCompletion:
                sessionType = SessionType.BP;
                getFileName = x => x.StagedBillPayTransactionLookup;
                break;

            case PurposeOfLookup.Amend:
                sessionType = SessionType.AMD;
                getFileName = x => x.AmendTransactionLookup;
                break;

            case PurposeOfLookup.SendReversal:
                sessionType = SessionType.SREV;
                getFileName = x => x.SendReversalTransactionLookup;
                break;

            case PurposeOfLookup.Status:
                response = TrainingModeConfiguration.GetTransactionLookupStatusResponse <TransactionLookupResponse>(referenceNumber, x => x.StatusTransactionLookup);
                break;
            }

            if (response == null)
            {
                response = TrainingModeConfiguration.GetResponse <TransactionLookupResponse>(sessionType.ToTrainingModeSessionType(), referenceNumber, getFileName);
            }

            var sendDate = response.Payload.CurrentValues.FirstOrDefault(x => x.InfoKey == "dateTimeSent");

            if (sendDate != null)
            {
                int.TryParse(sendDate.Value, out int daysAgo); //try to parse value from mock file. If it's int and parses it's added to current date. If parsing fails it is default of 0.
                sendDate.Value = DateTime.Now.AddDays(daysAgo).ToString("yyyy-MM-ddTHH:mm:ss.ffffzzz");
            }
            return(response);
        }
コード例 #3
0
 public bool IsStagedTransaction(SessionType sessionType, string mgiSessionId)
 {
     return(TrainingModeConfiguration.IsStagedTransaction(sessionType.ToTrainingModeSessionType(), mgiSessionId));
 }
コード例 #4
0
 public SearchStagedTransactionsResponse MockSearchStagedTransactionsResponse(SessionType transactionType)
 {
     if (transactionType == SessionType.SEND)
     {
         return(TrainingModeConfiguration.GetResponse <SearchStagedTransactionsResponse>(transactionType.ToTrainingModeSessionType(), null, x => x.StagedSendSearchTransactions));
     }
     if (transactionType == SessionType.BP)
     {
         return(TrainingModeConfiguration.GetResponse <SearchStagedTransactionsResponse>(transactionType.ToTrainingModeSessionType(), null, x => x.StagedBillPaySearchTransactions));
     }
     throw new ArgumentException("Unsupported transaction type");
 }