Exemple #1
0
        public async Task Process_Payment_Order_Change_Correctly()
        {
            var paymentOrderChangedEvent = new PaymentOrderChangedEvent()
            {
                AccountId    = 1,
                PaymentOrder = new [] { 300, 100, 200 }
            };

            var apprenticeshipProcessor = mocker.Create <ApprenticeshipProcessor>();
            await apprenticeshipProcessor.ProcessPaymentOrderChange(paymentOrderChangedEvent);

            mocker.Mock <IEndpointInstance>()
            .Verify(svc => svc.Publish(
                        It.Is <EmployerChangedProviderPriority>(ev => ev.EmployerAccountId == paymentOrderChangedEvent.AccountId &&
                                                                ev.OrderedProviders.Count == 3 &&
                                                                ev.OrderedProviders[0] == paymentOrderChangedEvent.PaymentOrder[0] &&
                                                                ev.OrderedProviders[1] == paymentOrderChangedEvent.PaymentOrder[1] &&
                                                                ev.OrderedProviders[2] == paymentOrderChangedEvent.PaymentOrder[2]),
                        It.IsAny <PublishOptions>()),
                    Times.Once);
        }
Exemple #2
0
        public async Task ProcessPaymentOrderChange(PaymentOrderChangedEvent paymentOrderChangedEvent)
        {
            try
            {
                logger.LogDebug($"Now processing Payment Order Changed Event for Account id: {paymentOrderChangedEvent.AccountId}");

                var priorityEvent = new EmployerChangedProviderPriority
                {
                    EmployerAccountId = paymentOrderChangedEvent.AccountId,
                    OrderedProviders  = paymentOrderChangedEvent.PaymentOrder.Select(x => (long)x).ToList()
                };

                var endpointInstance = await endpointInstanceFactory.GetEndpointInstance().ConfigureAwait(false);

                await endpointInstance.Publish(priorityEvent).ConfigureAwait(false);

                logger.LogDebug($"Finished processing Payment Order Changed Event for Account id: {paymentOrderChangedEvent.AccountId}");
            }
            catch (Exception ex)
            {
                logger.LogError($"Error processing Payment Order Changed Event. Error: {ex.Message}", ex);
                throw;
            }
        }
 public Task Handle(PaymentOrderChangedEvent message, IMessageHandlerContext context)
 {
     return(Log(message, context));
 }