Exemple #1
0
 /// <inheritdoc />
 public MessageBroker(ILogger logger, MessageBusConfig messageBusConfig, IQueueFactory queueFactory, IProcessInformation processInformation, IQueueNameUtility queueNameUtility)
 {
     _logger             = logger;
     _messageBusConfig   = messageBusConfig;
     _queueFactory       = queueFactory;
     _processInformation = processInformation;
     _queueNameUtility   = queueNameUtility;
     _messageBrokerQueue = _queueFactory.CreateLocale(MessageBrokerConfig.LocaleQueueName, true, LocaleQueueMode.Durable, true, AccessMode.Send);
 }
        public QueueHandlerSyncTests()
        {
            _queue = Substitute.For <ILocaleQueue>();

            _queueFactory = Substitute.For <IQueueFactory>();
            _queueFactory.CreateLocale(Arg.Any <string>(), Arg.Any <bool>(), Arg.Any <LocaleQueueMode>(), Arg.Any <bool>(), Arg.Any <AccessMode>()).Returns(_queue);
            _taskFactory = Substitute.For <ITaskFactory>();
            _taskFactory.Create().Returns(new SyncTestTask());
            _cancellationToken = new CancellationToken();
        }
        public QueueHandlerAsyncTests()
        {
            _queue = Substitute.For <ILocaleQueue>();
            _queue.Receive(Arg.Any <int>(), Arg.Any <CancellationToken>()).Returns(e => CreateMessage("Message1"), e => CreateMessage("Message2"), e => CreateMessage("Message3"), e => null);

            _queueFactory = Substitute.For <IQueueFactory>();
            _queueFactory.CreateLocale(Arg.Any <string>(), Arg.Any <bool>(), Arg.Any <LocaleQueueMode>(), Arg.Any <bool>(), Arg.Any <AccessMode>()).Returns(_queue);
            _taskFactory = new TaskFactory();

            _cancellationTokenSource = new CancellationTokenSource();
            _cancellationToken       = _cancellationTokenSource.Token;
        }
Exemple #4
0
        public MessageBrokerTests()
        {
            _messageBusConfig = new MessageBusConfig
            {
                ServiceName = "MessageBrokerTests"
            };

            _queueFactory       = Substitute.For <IQueueFactory>();
            _queueNameUtility   = new QueueNameUtility("UniTests");
            _processInformation = Substitute.For <IProcessInformation>();
            _processInformation.MachineName.Returns("TestServer");

            _cancellationToken = new CancellationToken();

            _messageBrokerQueue = Substitute.For <ILocaleQueue>();
            _messageBrokerQueue.Exists().Returns(true);
            _queueFactory.CreateLocale(MessageBrokerConfig.LocaleQueueName, Arg.Any <bool>(), Arg.Any <LocaleQueueMode>(), Arg.Any <bool>(), Arg.Any <AccessMode>()).Returns(_messageBrokerQueue);
        }