public void SetUp() { persistentConnection = MockRepository.GenerateStub<IPersistentConnection>(); channel = MockRepository.GenerateStub<IModel>(); var eventBus = new EventBus(); var configuration = new ConnectionConfiguration(); var shutdownArgs = new ShutdownEventArgs( ShutdownInitiator.Peer, AmqpException.ConnectionClosed, "connection closed by peer"); var exception = new OperationInterruptedException(shutdownArgs); var first = true; persistentConnection.Stub(x => x.CreateModel()).WhenCalled(x => { if (first) { first = false; throw exception; } x.ReturnValue = channel; }); var logger = MockRepository.GenerateStub<IEasyNetQLogger>(); persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus); new Timer(_ => eventBus.Publish(new ConnectionCreatedEvent())).Change(10, Timeout.Infinite); persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct")); }
public When_an_action_is_performed_on_a_closed_channel_that_then_opens() { persistentConnection = Substitute.For <IPersistentConnection>(); channel = Substitute.For <IModel>(); var eventBus = new EventBus(); var configuration = new ConnectionConfiguration(); var shutdownArgs = new ShutdownEventArgs( ShutdownInitiator.Peer, AmqpException.ConnectionClosed, "connection closed by peer"); var exception = new OperationInterruptedException(shutdownArgs); persistentConnection.CreateModel().Returns(x => { throw exception; }, x => channel, x => channel); var logger = Substitute.For <IEasyNetQLogger>(); persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus); new Timer(_ => eventBus.Publish(new ConnectionCreatedEvent()), null, 10, Timeout.Infinite); persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct")); }
public void Should_throw_timeout_exception() { Assert.Throws <TimeoutException>(() => { persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct")); }); }
public void SetUp() { persistentConnection = MockRepository.GenerateStub <IPersistentConnection>(); channel = MockRepository.GenerateStub <IModel>(); var eventBus = new EventBus(); var configuration = new ConnectionConfiguration(); var shutdownArgs = new ShutdownEventArgs( ShutdownInitiator.Peer, AmqpException.ConnectionClosed, "connection closed by peer"); var exception = new OperationInterruptedException(shutdownArgs); var first = true; persistentConnection.Stub(x => x.CreateModel()).WhenCalled(x => { if (first) { first = false; throw exception; } x.ReturnValue = channel; }); var logger = MockRepository.GenerateStub <IEasyNetQLogger>(); persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus); new Timer(_ => eventBus.Publish(new ConnectionCreatedEvent())).Change(10, Timeout.Infinite); persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct")); }
public void Should_throw_timeout_exception() { Assert.Throws <TaskCanceledException>(() => { using var cts = new CancellationTokenSource(1000); persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct"), cts.Token); }); }
public When_a_channel_action_is_invoked() { persistentConnection = Substitute.For <IPersistentConnection>(); channel = Substitute.For <IModel>(); var configuration = new ConnectionConfiguration(); eventBus = Substitute.For <IEventBus>(); persistentConnection.CreateModel().Returns(channel); persistentChannel = new PersistentChannel(persistentConnection, configuration, eventBus); persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct")); }
public void SetUp() { persistentConnection = MockRepository.GenerateStub<IPersistentConnection>(); channel = MockRepository.GenerateStub<IModel>(); var configuration = new ConnectionConfiguration(); eventBus = MockRepository.GenerateStub<IEventBus>(); persistentConnection.Stub(x => x.CreateModel()).Return(channel); var logger = MockRepository.GenerateStub<IEasyNetQLogger>(); persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus); persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct"),DateTime.UtcNow ); }
public void SetUp() { persistentConnection = MockRepository.GenerateStub <IPersistentConnection>(); channel = MockRepository.GenerateStub <IModel>(); var configuration = new ConnectionConfiguration(); eventBus = MockRepository.GenerateStub <IEventBus>(); persistentConnection.Stub(x => x.CreateModel()).Return(channel); var logger = MockRepository.GenerateStub <IEasyNetQLogger>(); persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus); persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct")); }
public void SetUp() { persistentConnection = MockRepository.GenerateStub <IPersistentConnection>(); channel = MockRepository.GenerateStub <IModel>(); var eventBus = new EventBus(); var configuration = new ConnectionConfiguration(); var shutdownArgs = new ShutdownEventArgs( ShutdownInitiator.Peer, AmqpException.ConnectionClosed, "connection closed by peer"); var exception = new OperationInterruptedException(shutdownArgs); persistentConnection.Stub(x => x.CreateModel()).Throw(exception).Repeat.Once(); persistentConnection.Stub(x => x.CreateModel()).Return(channel).Repeat.Any(); var logger = MockRepository.GenerateStub <IEasyNetQLogger>(); persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus); new Timer(_ => eventBus.Publish(new ConnectionCreatedEvent())).Change(10, Timeout.Infinite); persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct"), DateTime.UtcNow); }
public void SetUp() { persistentConnection = MockRepository.GenerateStub<IPersistentConnection>(); channel = MockRepository.GenerateStub<IModel>(); var eventBus = new EventBus(); var configuration = new ConnectionConfiguration(); var shutdownArgs = new ShutdownEventArgs( ShutdownInitiator.Peer, AmqpException.ConnectionClosed, "connection closed by peer"); var exception = new OperationInterruptedException(shutdownArgs); persistentConnection.Stub(x => x.CreateModel()).Throw(exception).Repeat.Once(); persistentConnection.Stub(x => x.CreateModel()).Return(channel).Repeat.Any(); var logger = MockRepository.GenerateStub<IEasyNetQLogger>(); persistentChannel = new PersistentChannel(persistentConnection, logger, configuration, eventBus); new Timer(_ => eventBus.Publish(new ConnectionCreatedEvent())).Change(10, Timeout.Infinite); persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct"),DateTime.UtcNow ); }
public void Should_be_able_to_run_channel_actions() { persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("myExchange", "direct")); }
public void Should_be_able_to_run_channel_actions() { persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("myExchange", "direct", true, false, new Dictionary <string, object>())); }
public void Should_throw_timeout_exception() { persistentChannel.InvokeChannelAction(x => x.ExchangeDeclare("MyExchange", "direct"), DateTime.UtcNow); }