public void Should_should_locate_singleton_processors()
        {
            //arrange
            var locator = new MessageProcessorLocator(new HostConfiguration
            {
                DependencyInjection  = _messageHandlerProvider,
                SingletonLockManager = Mock.Of <ISingletonLockManager>()
            }, new[] { _queueStarterFactory.Object });
            var underlyingQueueStarter = new Mock <IChannelReceiver>();

            underlyingQueueStarter.Setup(x => x.Settings).Returns(new SingletonProcessingSettings
            {
                MessageLockTimeout      = TimeSpan.FromMinutes(1),
                DeadLetterDeliveryLimit = 1
            });
            _queueStarterFactory.Setup(x => x.CanCreate(typeof(SingletonCommand))).Returns(true);
            _queueStarterFactory.Setup(x => x.Create(typeof(SingletonCommand), null, It.IsAny <TestTopicSettings>(), It.IsAny <IHostConfiguration>(), It.IsAny <IMessageProcessor>()))
            .Returns(underlyingQueueStarter.Object).Verifiable();
            _messageHandlerProvider.RegisterProcessor(new SingletonCommandProcessor());
            //act
            var reader = Enumerable.ToList(locator.Locate());
            //assert
            var valid = reader.Where(x => x is SingletonChannelReceiver).ToList();

            valid.Count.Should().Be(1);
        }
        public void Should_throw_when_message_transport_is_unknown()
        {
            //arrange
            var locator = new MessageProcessorLocator(new HostConfiguration
            {
                DependencyInjection = _messageHandlerProvider,
            }, new[] { _queueStarterFactory.Object });

            _queueStarterFactory.Setup(x => x.CanCreate(typeof(TestCommand))).Returns(false);
            _messageHandlerProvider.RegisterProcessor(new SingleCommandProcessor(Mock.Of <ICountable>()));
            //act and assert
            AssertionExtensions.Invoking(locator, x => Enumerable.ToList(x.Locate())).Should().Throw <TransportMissingException>();
        }
        public void Should_locate_event_processors()
        {
            //arrange
            var locator = new MessageProcessorLocator(new HostConfiguration
            {
                DependencyInjection = _messageHandlerProvider,
            }, new[] { _queueStarterFactory.Object });

            _queueStarterFactory.Setup(x => x.CanCreate(typeof(TestEvent))).Returns(true);
            _queueStarterFactory.Setup(x => x.Create(typeof(TestEvent), It.IsAny <TestSubscription>(), It.IsAny <TestTopicSettings>(), It.IsAny <HostConfiguration>(), It.IsAny <IMessageProcessor>()))
            .Returns(Mock.Of <IChannelReceiver>()).Verifiable();
            _messageHandlerProvider.RegisterProcessor(new EventProcessor(Mock.Of <ICountable>()));
            //act
            var reader = Enumerable.ToList(locator.Locate());

            //assert
            reader.Count.Should().Be(1);
            _queueStarterFactory.Verify();
        }
Ejemplo n.º 4
0
        public void Should_locate_single_command_processor()
        {
            //arrange
            var locator = new MessageProcessorLocator(new HostConfiguration
            {
                MessageProcessorProvider = _messageHandlerProvider
            }, new[] { _queueStarterFactory.Object });

            _queueStarterFactory.Setup(x => x.CanCreate(typeof(TestCommand))).Returns(true);
            _queueStarterFactory.Setup(x => x.Create(typeof(TestCommand), null, typeof(TestTopicSettings), It.IsAny <HostConfiguration>(), It.IsAny <IMessageProcessor>()))
            .Returns(Mock.Of <IChannelReceiver>()).Verifiable();
            _messageHandlerProvider.RegisterProcessor(new SingleCommandProcessor(Mock.Of <ICountable>()));
            //act
            var reader = Enumerable.ToList(locator.Locate());

            //assert
            reader.Count.Should().Be(1);
            _queueStarterFactory.Verify();
        }