コード例 #1
0
ファイル: BaseQueueTaskTest.cs プロジェクト: ognjenm/egle
            public void ExecuteTaskWhenValidItemCallsAppropriateMethods()
            {
                // Arrange
                var queueManagerMock = MockRepository.GenerateMock<QueueManager>(new DbDrivenQueueProcessor());
                var providerSubscriberMock = MockRepository.GenerateMock<IProviderAndSubscriberOptinService>();
                IQueueItem queMock = new QueueItem
                {
                    Id = 1,
                    QueueCode = QueueCodeType.PushIntegrationInventory
                };
                
                queueManagerMock.Expect(
                    qmm =>
                    qmm.GetQueueItem(
                        Arg<IQueueItem>.Matches(iq => iq.QueueCode == QueueCodeType.PushIntegrationInventory)))
                                .Return(queMock)
                                .Repeat.Once();
                queueManagerMock.Expect(
                    qmm => qmm.ProcessQueueItem(Arg<IQueueItem>.Matches(iq => iq.Id == queMock.Id))).Repeat.Once();
                // handle the one call when used in base constructor
                queueManagerMock.Expect(qmm => qmm.ResetStaleQueueItems()).Repeat.Once();

                AigInventoryChangeTask aigInventoryTaskMock = MockRepository.GeneratePartialMock<AigInventoryChangeTask>(queueManagerMock);
                aigInventoryTaskMock.State = TaskState.Running;
                
                providerSubscriberMock.Expect(psm => psm.Load()).Repeat.AtLeastOnce();
                

                aigInventoryTaskMock.ProviderSubscriberOptInService = providerSubscriberMock;
                aigInventoryTaskMock.QueueManager = queueManagerMock;

                aigInventoryTaskMock.Expect(
                    ait => ait.ProcessRequest(Arg<IQueueItem>.Matches(iq => iq.Id == queMock.Id)))
                                    .Return(true)
                                    .Repeat.Once();
                aigInventoryTaskMock.Expect(
                    ait => ait.ValidateRequest(Arg<IQueueItem>.Matches(iq => iq.Id == queMock.Id)))
                                    .Return(true)
                                    .Repeat.Once();

                // Act
                aigInventoryTaskMock.ExecuteTask();

                // Assert by verify
                providerSubscriberMock.VerifyAllExpectations();
                queueManagerMock.VerifyAllExpectations();
                aigInventoryTaskMock.VerifyAllExpectations();
            }
コード例 #2
0
ファイル: AddItemMapper.cs プロジェクト: ognjenm/egle
        public QueueItem Execute(QueueItem queueItem)
        {
            // in parameters
            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(Parameters.QueueCode, queueItem.QueueCode.GetCode()),
                DbHelper.CreateParameter(Parameters.UserId, queueItem.UserId),
                DbHelper.CreateParameter(Parameters.ItemKey, queueItem.Key),
                DbHelper.CreateParameter(Parameters.Payload, queueItem.Payload),
                DbHelper.CreateParameter(Parameters.PayloadTypeCode, queueItem.PayloadType.GetCode())
            };

            // out parameters
            SqlParameter outputItemId;
            parameters.Add(outputItemId = DbHelper.CreateParameterOut<int>(OutParameters.ItemId, SqlDbType.Int));
            
            DbHelper.ExecuteNonQueryCommand(this, parameters);
            queueItem.Id = DbHelper.ParameterValue<int?>(outputItemId);

            return queueItem;
        }
コード例 #3
0
ファイル: PaymentManager.cs プロジェクト: ognjenm/egle
        /// <summary>
        /// Add a queueItem based on the payment and invoice request
        /// </summary>
        /// <param name="payment">payment information</param>
        /// <param name="payload">invoice request</param>
        /// <returns>queue item with id set</returns>
        virtual internal QueueItem GetSettlementQueueItemFromPayment(Payment payment, SettlementInvoiceRequest payload)
        {
            QueueItem queItem = null;
            if (payload.IsValid())
            {
                // create queue item from payment sent in
                queItem = new QueueItem
                    {
                        Key = payment.OrderId.ToString(),
                        PayloadType = PayloadTypeEnum.BookingInv,
                        QueueCode = QueueCodeType.SettlementInvoiceRequest,
                        UserId = payment.CreatedByUserId,
                        Payload = XmlSerialization.XmlSerializeToString(payload)
                    };
            }

            return queItem;
        }
コード例 #4
0
ファイル: QueueManager.cs プロジェクト: ognjenm/egle
 /// <summary>
 /// Add a queueItem based on the payment and invoice request
 /// </summary>
 /// <param name="queItem">queue item to add</param>
 /// <returns>queue item with id set</returns>
 public QueueItem AddQueueItem(QueueItem queItem)
 {
     return queueDao.AddQueueItem(queItem);
 }
コード例 #5
0
ファイル: BaseQueueTaskTest.cs プロジェクト: ognjenm/egle
            public void ExecuteTaskHandlesRetriesSuccessfully()
            {
                // Arrange
                var queueManagerMock = MockRepository.GenerateMock<QueueManager>(new DbDrivenQueueProcessor());
                var providerSubscriberMock = MockRepository.GenerateMock<IProviderAndSubscriberOptinService>();
                IQueueItem queMock = new QueueItem
                {
                    Id = 1,
                    QueueCode = QueueCodeType.PushIntegrationInventory
                };

                queueManagerMock.Expect(
                    qmm =>
                    qmm.GetQueueItem(
                        Arg<IQueueItem>.Matches(iq => iq.QueueCode == QueueCodeType.PushIntegrationInventory)))
                                .Return(queMock)
                                .Repeat.Once();

                // since the task fails this won't happen
                queueManagerMock.Expect(
                    qmm => qmm.ProcessQueueItem(Arg<IQueueItem>.Matches(iq => iq.Id == queMock.Id))).Repeat.Never();
                // handle the one call when used in base constructor
                queueManagerMock.Expect(qmm => qmm.ResetStaleQueueItems()).Repeat.Once();

                AigInventoryChangeTask aigInventoryTaskMock = MockRepository.GeneratePartialMock<AigInventoryChangeTask>(queueManagerMock);
                aigInventoryTaskMock.State = TaskState.Running;

                providerSubscriberMock.Expect(psm => psm.Load()).Repeat.AtLeastOnce();


                aigInventoryTaskMock.ProviderSubscriberOptInService = providerSubscriberMock;
                aigInventoryTaskMock.QueueManager = queueManagerMock;

                // return false showing failure in execution
                aigInventoryTaskMock.Expect(
                    ait => ait.ProcessRequest(Arg<IQueueItem>.Matches(iq => iq.Id == queMock.Id)))
                                    .Return(false)
                                    .Repeat.Once();
                aigInventoryTaskMock.Expect(
                    ait => ait.ValidateRequest(Arg<IQueueItem>.Matches(iq => iq.Id == queMock.Id)))
                                    .Return(true)
                                    .Repeat.Once();

                aigInventoryTaskMock.Expect(
                    ait =>
                    ait.ScheduleRetryAndHandleFailure(Arg<IQueueItem>.Matches(iq => iq.Id == queMock.Id),
                                                      Arg<Exception>.Is.Null)).Repeat.Once();

                // Act
                aigInventoryTaskMock.ExecuteTask();

                // Assert by verify
                providerSubscriberMock.VerifyAllExpectations();
                queueManagerMock.VerifyAllExpectations();
                aigInventoryTaskMock.VerifyAllExpectations();

            }  
コード例 #6
0
ファイル: QueueDao.cs プロジェクト: ognjenm/egle
 /// <summary>
 /// Add the given item to the eagle queue
 /// </summary>
 /// <param name="queueItem">queue item to add</param>
 /// <returns>queue item with id set</returns>
 public QueueItem AddQueueItem(QueueItem queueItem)
 {
     return new StoredProcedures.Queue.AddItemMapper().Execute(queueItem);
 }