public void Does_execute_validation_filters()
        {
            using (var mqFactory = appHost.TryResolve <IMessageFactory>())
            {
                var request = new ValidateTestMq {
                    Id = -10
                };

                using (var mqProducer = mqFactory.CreateMessageProducer())
                    using (var mqClient = mqFactory.CreateMessageQueueClient())
                    {
                        mqProducer.Publish(request);

                        var errorMsg = mqClient.Get <ValidateTestMq>(QueueNames <ValidateTestMq> .Dlq, null);
                        mqClient.Ack(errorMsg);

                        Assert.That(errorMsg.Error.ErrorCode, Is.EqualTo("PositiveIntegersOnly"));

                        request = new ValidateTestMq {
                            Id = 10
                        };
                        mqProducer.Publish(request);
                        var responseMsg = mqClient.Get <ValidateTestMqResponse>(QueueNames <ValidateTestMqResponse> .In, null);
                        mqClient.Ack(responseMsg);
                        Assert.That(responseMsg.GetBody().CorrelationId, Is.EqualTo(request.Id));
                    }
            }
        }
Esempio n. 2
0
        public void Does_execute_validation_filters()
        {
            using (var mqFactory = appHost.TryResolve <IMessageFactory>())
            {
                var request = new ValidateTestMq {
                    Id = -10
                };
                mqFactory.CreateMessageProducer().Publish(request);
                var msg = mqFactory.CreateMessageQueueClient().Get(QueueNames <ValidateTestMqResponse> .Dlq, null)
                          .ToMessage <ValidateTestMqResponse>();

                msg.GetBody().PrintDump();
                Assert.That(msg.GetBody().ResponseStatus.ErrorCode, Is.EqualTo("PositiveIntegersOnly"));

                request = new ValidateTestMq {
                    Id = 10
                };
                mqFactory.CreateMessageProducer().Publish(request);
                msg = mqFactory.CreateMessageQueueClient().Get(QueueNames <ValidateTestMqResponse> .In, null)
                      .ToMessage <ValidateTestMqResponse>();
                Assert.That(msg.GetBody().CorrelationId, Is.EqualTo(request.Id));
            }
        }
        public void Does_execute_ReplyTo_validation_filters()
        {
            using (var mqFactory = appHost.TryResolve <IMessageFactory>())
            {
                var request = new ValidateTestMq {
                    Id = -10
                };

                using (var mqProducer = mqFactory.CreateMessageProducer())
                    using (var mqClient = mqFactory.CreateMessageQueueClient())
                    {
                        var requestMsg = new Message <ValidateTestMq>(request)
                        {
                            ReplyTo = "mq:{0}.replyto".Fmt(request.GetType().Name)
                        };
                        mqProducer.Publish(requestMsg);

                        var errorMsg = mqClient.Get <ValidateTestMqResponse>(requestMsg.ReplyTo, null);
                        mqClient.Ack(errorMsg);

                        errorMsg.GetBody().PrintDump();
                        Assert.That(errorMsg.GetBody().ResponseStatus.ErrorCode, Is.EqualTo("PositiveIntegersOnly"));

                        request = new ValidateTestMq {
                            Id = 10
                        };
                        requestMsg = new Message <ValidateTestMq>(request)
                        {
                            ReplyTo = "mq:{0}.replyto".Fmt(request.GetType().Name)
                        };
                        mqProducer.Publish(requestMsg);
                        var responseMsg = mqClient.Get <ValidateTestMqResponse>(requestMsg.ReplyTo, null);
                        mqClient.Ack(responseMsg);
                        Assert.That(responseMsg.GetBody().CorrelationId, Is.EqualTo(request.Id));
                    }
            }
        }
 public object Post(ValidateTestMq request)
 {
     return(new ValidateTestMqResponse {
         CorrelationId = request.Id
     });
 }