public void DependencySubscribe() { var(messageProvider, queueProviderSettings, connectionFactory) = RabbitMockFactory.Get(); var queueWatcherRabbitMQ = new QueueWatcherRabbitMQ(messageProvider.Object, queueProviderSettings.Object); Assert.Throws <ArgumentNullException>("Subscribe", () => { queueWatcherRabbitMQ.StartWatch("queue1"); }); }
public void StartWatch() { var(messageProvider, queueProviderSettings, connectionFactory) = RabbitMockFactory.Get(); var queueWatcherRabbitMQ = new QueueWatcherRabbitMQ(messageProvider.Object, connectionFactory.Object); var @event = new ManualResetEvent(false); IQueueMessage message = null; queueWatcherRabbitMQ.Subscribe += (IQueueMessage mess) => Task.Run(() => { message = mess; @event.Set(); }); Task.Factory.StartNew(() => queueWatcherRabbitMQ.StartWatch("queue1")); @event.WaitOne(); Assert.NotNull(message); Assert.Equal("Hi", message.Body); }