private void InitialCardPaymentRequestWorkers()
        {
            CardPaymentProcessor cardPaymentProcessor = new CardPaymentProcessor(ObjectFactory.GetInstance <IMailService>(), ObjectFactory.GetInstance <IRedisService>(), ObjectFactory.GetInstance <IRESTfulClient>());

            Action <object> q0Action = (object param) =>
            {
                while (true)
                {
                    try
                    {
                        //LogHelper.WriteInfo("Sending Card Payment Request To YP from thread : " + param);
                        cardPaymentProcessor.SendCardPaymentRequestToYP();
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteError(string.Format("{0}\r\n{1}", ex.Message, ex.StackTrace));
                    }
                }
            };

            Action <object> q3Action = (object param) =>
            {
                while (true)
                {
                    try
                    {
                        //LogHelper.WriteInfo("Sending CallBack from thread : " + param, ConsoleColor.Green);
                        cardPaymentProcessor.SendCardPaymentCallBack();
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteError(string.Format("{0}\r\n{1}", ex.Message, ex.StackTrace));
                    }
                }
            };

            for (int i = 0; i < "WorkerNumber".ConfigValue().ToInt32(); i++)
            {
                Task q0Worker = Task.Factory.StartNew(q0Action, i);
                Task q3Worker = Task.Factory.StartNew(q3Action, i);
            }
        }
Beispiel #2
0
        public CardPaymentProcessorTest()
        {
            _redisServiceMock = new Mock <IRedisService>();
            redisService      = _redisServiceMock.Object;

            _repository    = new Mock <IRepository>();
            mockRepository = _repository.Object;

            _paymentsServiceMock = new Mock <IMailService>();
            paymentsService      = _paymentsServiceMock.Object;

            _restfulClientMock = new Mock <IRESTfulClient>();
            restfulClient      = _restfulClientMock.Object;

            cardPaymentProcessor            = new CardPaymentProcessor(paymentsService, redisService, restfulClient);
            cardPaymentProcessor.oracleRepo = mockRepository;

            cp.RequestDateTime = DateTime.Now;
            currentOrder.Id    = (int)cp.OrderID;
            Bootstrapper.Start();
        }