public async Task Should_work_when_reconnected() { async Task ConnectAndConsume() { var correlationId = NewId.NextGuid(); Task <ConsumeContext <PingMessage> > pingHandled = null; var handle = Bus.ConnectReceiveEndpoint("second_queue", x => { pingHandled = Handled <PingMessage>(x, context => context.Message.CorrelationId == correlationId); ((IServiceBusReceiveEndpointConfigurator)x).RemoveSubscriptions = true; }); await handle.Ready; try { await Bus.Publish(new PingMessage(correlationId)); ConsumeContext <PingMessage> pinged = await pingHandled; Assert.That(pinged.ReceiveContext.InputAddress, Is.EqualTo(new Uri(string.Join("/", HostAddress.GetLeftPart(UriPartial.Path), "second_queue")))); } finally { await handle.StopAsync(); } } await ConnectAndConsume(); await ConnectAndConsume(); }
public async Task Should_be_allowed() { Task <ConsumeContext <PingMessage> > pingHandled = null; var handle = Bus.ConnectReceiveEndpoint("second_queue", x => { pingHandled = Handled <PingMessage>(x); ((IServiceBusReceiveEndpointConfigurator)x).RemoveSubscriptions = true; }); await handle.Ready; try { await Bus.Publish(new PingMessage()); ConsumeContext <PingMessage> pinged = await pingHandled; Assert.That(pinged.ReceiveContext.InputAddress, Is.EqualTo(new Uri(string.Join("/", HostAddress.GetLeftPart(UriPartial.Path), "second_queue")))); } finally { await handle.StopAsync(); } }