Ejemplo n.º 1
0
        public async Task Handle(DoP2pRefresh message, IMessageHandlerContext context)
        {
            var warningPolicy = new P2pWorkflowWarningPolicy {
                WorkflowId = message.WorkflowId
            };
            var requestTimeoutMinutes = Properties.Settings.Default.SagaRequestTimeoutMinutes;

            await RequestTimeout(context, TimeSpan.FromMinutes(requestTimeoutMinutes), warningPolicy);

            var events = new P2pWorkflowStarted {
                WorkflowId = message.WorkflowId
            };
            await context.Publish(events).ConfigureAwait(false);

            _logger.Info($"{message.WorkflowId} started.");
        }
        public async Task HandleTest()
        {
            var handler = new Handlers.P2pWorkflowStartedHandler("Data Source=.;Initial Catalog=PdpDb;Integrated Security=True;");
            var context = new TestableMessageHandlerContext();
            var message = new P2pWorkflowStarted()
            {
                WorkflowId = Guid.NewGuid()
            };
            await handler.Handle(message, context);

            var publishedMessages = context.PublishedMessages;

            handler.ShouldSatisfyAllConditions(() =>
            {
                publishedMessages.Containing <P2pPolled>().Any(t => t.Message.WorkflowId == message.WorkflowId && t.Message.Customers != null).ShouldBe(true);
            });
        }