public async Task DispatchAsync_Should_Sent_To_FirstNamespacePart_By_Convention() { try { var networkInfos = RabbitNetworkInfos.GetConfigurationFor("CQELight", RabbitMQExchangeStrategy.Custom); networkInfos.ServiceQueueDescriptions.Add(new RabbitQueueDescription("CQELight")); var config = new RabbitPublisherConfiguration { ConnectionInfos = GetConnectionInfos(), NetworkInfos = networkInfos }; var publisher = new RabbitPublisher( loggerFactory, config); await publisher.DispatchAsync(new TestCommand()); var result = channel.BasicGet("CQELight", true); result.Should().NotBeNull(); Encoding.UTF8.GetString(result.Body.ToArray()).FromJson <TestCommand>().Should().NotBeNull(); } finally { DeleteData(); } }
public async Task DispatchAsync_Default_Routing_Key_Factory_Should_Be_Considered() { try { var fakeRoutingKeyFactory = new Mock <IRoutingKeyFactory>(); fakeRoutingKeyFactory .Setup(m => m.GetRoutingKeyForCommand(It.IsAny <object>())) .Returns("MyCustomQueue"); var networkInfos = RabbitNetworkInfos.GetConfigurationFor("CQELight", RabbitMQExchangeStrategy.Custom); networkInfos.ServiceQueueDescriptions.Add(new RabbitQueueDescription("CQELight")); networkInfos.ServiceQueueDescriptions.Add(new RabbitQueueDescription("MyCustomQueue")); var config = new RabbitPublisherConfiguration { ConnectionInfos = GetConnectionInfos(), NetworkInfos = networkInfos, RoutingKeyFactory = fakeRoutingKeyFactory.Object }; var publisher = new RabbitPublisher( loggerFactory, config); await publisher.DispatchAsync(new TestCommand()); channel.BasicGet("CQELight", true).Should().BeNull(); var result = channel.BasicGet("MyCustomQueue", true); result.Should().NotBeNull(); Encoding.UTF8.GetString(result.Body.ToArray()).FromJson <TestCommand>().Should().NotBeNull(); } finally { DeleteData(); channel.QueueDelete("MyCustomQueue"); } }