public RabbitConsumerInitializer( IRabbitMqPersistentConnection persistentConnection, IOptions <RabbitMqEventBusOptions> options, IRabbitConsumerHandler rabbitConsumerHandler, ILogger <RabbitConsumerInitializer> logger) { _persistentConnection = persistentConnection; _rabbitConsumerHandler = rabbitConsumerHandler; _logger = logger; _rabbitMqEventBusOptions = options.Value; EnsureQueueAndExchangeAreCreated(); }
public void SetUp() { _rabbitMqPersistentConnection = Substitute.For <IRabbitMqPersistentConnection>(); _rabbitConsumerHandler = Substitute.For <IRabbitConsumerHandler>(); var rabbitMqEventBusOptions = Substitute.For <IOptions <RabbitMqEventBusOptions> >(); var value = Substitute.For <RabbitMqEventBusOptions>(); rabbitMqEventBusOptions.Value.Returns(value); _rabbitMqEventBusOptions = value; var queueName = Guid.NewGuid().ToString(); var exchangeName = Guid.NewGuid().ToString(); value.QueueName.Returns(queueName); value.ExchangeName.Returns(exchangeName); _model = Substitute.For <IModel>(); _rabbitMqPersistentConnection.CreateModel().Returns(_model); _consumer = Substitute.For <EventingBasicConsumer>(Substitute.For <IModel>()); _rabbitMqPersistentConnection.CreateConsumer(_model).Returns(_consumer); _sut = new RabbitConsumerInitializer(_rabbitMqPersistentConnection, rabbitMqEventBusOptions, _rabbitConsumerHandler, Substitute.For <ILogger <RabbitConsumerInitializer> >()); }