public void Should_be_able_to_send_a_message_to_a_routed_queue() { var command = new SimpleCommand { Name = Guid.NewGuid().ToString() }; var configuration = CreateMemoryConfiguration(); var module = new ServiceBusRoutingModule(); configuration.Modules.Add(module); var mockMessageRouteProvider = new Mock<IMessageRouteProvider>(); mockMessageRouteProvider.Setup(mock => mock.GetRouteUris(It.IsAny<object>())).Returns(new List<string> { configuration.Inbox.WorkQueue.Uri.ToString() }); configuration.MessageRouteProvider = mockMessageRouteProvider.Object; using (var bus = new ServiceBus(configuration)) { bus.Start(); bus.Send(command); var timeout = DateTime.Now.AddMilliseconds(5000); while (DateTime.Now < timeout && module.SimpleCommand == null) { Thread.Sleep(50); } Assert.IsNotNull(module.SimpleCommand); Assert.AreEqual(command.Name, module.SimpleCommand.Name); } }
public void Should_be_able_to_send_a_message_to_a_routed_queue() { var command = new SimpleCommand { Name = Guid.NewGuid().ToString() }; var configuration = CreateMemoryConfiguration(); var mockMessageRouteProvider = Mock<IMessageRouteProvider>(); mockMessageRouteProvider.Stub(mock => mock.GetRouteUris(Arg<object>.Is.Anything)).Return(new List<string> { configuration.Inbox.WorkQueue.Uri.ToString() }); configuration.MessageRouteProvider = mockMessageRouteProvider; using (var bus = new ServiceBus(configuration)) { bus.Configuration.Modules.Add(new MockModule(this)); bus.Start(); bus.Send(command); var waitTill = DateTime.Now.AddMilliseconds(15000); while (DateTime.Now < waitTill && TransportMessage == null) { Thread.Sleep(50); } Assert.IsNotNull(TransportMessage); Assert.AreEqual(command.Name, ((SimpleCommand)bus.Configuration.Serializer.Deserialize(typeof(SimpleCommand), new MemoryStream(TransportMessage.Message))).Name); } }