Ejemplo n.º 1
0
        public QueueReactorFactory Please()
        {
            var messageAdapterFactory = new Mock <IMessageAdapterFactory>();

            messageAdapterFactory
            .Setup(x => x.Create(It.IsAny <string>()))
            .Returns(_messageAdapter ?? Given.MessageAdapter.Please());

            var healthCheckingService = new Mock <IHealthCheckingService>();

            var fakeContextAccessor = new Mock <MessagingCallContextAccessor>();

            var factory = new QueueReactorFactory(
                messageAdapterFactory.Object,
                _messageProcessors.Select(d => d.messageProcessor),
                _messageProcessorsAsync.Select(d => d.messageProcessor),
                healthCheckingService.Object,
                fakeContextAccessor.Object,
                Given.FakeLoggerFactory
                );

            foreach (var processorData in _messageProcessors.Where(d => !string.IsNullOrEmpty(d.queueName)))
            {
                factory.Register(processorData.messageProcessor.GetType(), processorData.queueName);
            }
            foreach (var processorData in _messageProcessorsAsync.Where(d => !string.IsNullOrEmpty(d.queueName)))
            {
                factory.Register(processorData.messageProcessor.GetType(), processorData.queueName);
            }

            return(factory);
        }
        public void RegisterTest()
        {
            var          fakeContextAccessor = new Mock <MessagingCallContextAccessor>();
            const string queueName           = "ReQueueName";
            var          queueReactorFactory = new QueueReactorFactory(_messageAdapterFactory.Object, _messageProcessors,
                                                                       _asyncMessageProcessors, _healthCheckingService.Object, fakeContextAccessor.Object);

            var result = queueReactorFactory.Register <object>(queueName);

            Assert.Multiple(() =>
            {
                Assert.That(result, Is.Not.Null);
                Assert.Throws <MessageProcessorAlreadyRegisterException>(() =>
                {
                    queueReactorFactory.Register <object>(queueName);
                });
            });
        }