public OutboundQueueWorkerTests() { _queue = new InMemoryOutboundQueue(); var services = new ServiceCollection(); services .AddSingleton <ILoggerFactory, NullLoggerFactory>() .AddSingleton(typeof(ILogger <>), typeof(NullLogger <>)) .AddSingleton <IOutboundQueueConsumer, InMemoryOutboundQueue>() .AddBus() .AddBroker <TestBroker>(options => options.AddDeferredOutboundConnector(_ => new InMemoryOutboundQueue())); var serviceProvider = services.BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true }); serviceProvider.GetRequiredService <IOutboundRoutingConfiguration>() .Add <IIntegrationMessage>(TestEndpoint.Default); _broker = (TestBroker)serviceProvider.GetRequiredService <IBroker>(); _broker.Connect(); _worker = new OutboundQueueWorker(serviceProvider, _broker, new NullLogger <OutboundQueueWorker>(), new MessageLogger(new MessageKeyProvider(new[] { new DefaultPropertiesMessageKeyProvider() })), true, 100); // TODO: Test order not enforced InMemoryOutboundQueue.Clear(); }
public OutboundQueueWorkerTests() { _queue = new InMemoryOutboundQueue(); var services = new ServiceCollection(); services .AddSingleton <ILoggerFactory, NullLoggerFactory>() .AddSingleton(typeof(ILogger <>), typeof(NullLogger <>)) .AddSingleton <IOutboundQueueConsumer, InMemoryOutboundQueue>() .AddSilverback().WithConnectionTo <TestBroker>(options => options.AddDeferredOutboundConnector(_ => new InMemoryOutboundQueue())); var serviceProvider = services.BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true }); serviceProvider.GetRequiredService <IOutboundRoutingConfiguration>() .Add <IIntegrationMessage>(TestEndpoint.GetDefault()); _broker = (TestBroker)serviceProvider.GetRequiredService <IBroker>(); _broker.Connect(); _worker = new OutboundQueueWorker(serviceProvider, _broker, new NullLogger <OutboundQueueWorker>(), new MessageLogger(), true, 100); // TODO: Test order not enforced InMemoryOutboundQueue.Clear(); _sampleOutboundMessage = new OutboundMessage <TestEventOne>( new TestEventOne { Content = "Test" }, null, TestEndpoint.GetDefault()); _sampleOutboundMessage.RawContent = new JsonMessageSerializer().Serialize(_sampleOutboundMessage.Content, _sampleOutboundMessage.Headers); }
public async Task Bind_PushMessages_MessagesReceived() { _connector.Bind(TestEndpoint.GetDefault()); _broker.Connect(); var consumer = _broker.Consumers.First(); await consumer.TestPush(new TestEventOne { Id = Guid.NewGuid() }, offset : new TestOffset("a", "1")); await consumer.TestPush(new TestEventTwo { Id = Guid.NewGuid() }, offset : new TestOffset("a", "2")); _testSubscriber.ReceivedMessages.Count.Should().Be(2); }
public void Bind_PushMessages_MessagesReceived() { _connector.Bind(TestEndpoint.Default); _broker.Connect(); var consumer = _broker.Consumers.First(); consumer.TestPush(new TestEventOne { Id = Guid.NewGuid() }); consumer.TestPush(new TestEventTwo { Id = Guid.NewGuid() }); _testSubscriber.ReceivedMessages.Count.Should().Be(2); }