public void A_response_should_be_published_if_no_reply_address_is_specified() { PingMessage ping = new PingMessage(); TestMessageConsumer <PongMessage> otherConsumer = new TestMessageConsumer <PongMessage>(); RemoteBus.Subscribe(otherConsumer); TestCorrelatedConsumer <PongMessage, Guid> consumer = new TestCorrelatedConsumer <PongMessage, Guid>(ping.CorrelationId); LocalBus.Subscribe(consumer); FutureMessage <PongMessage> pong = new FutureMessage <PongMessage>(); RemoteBus.Subscribe <PingMessage>(message => { pong.Set(new PongMessage(message.CorrelationId)); CurrentMessage.Respond(pong.Message); }); LocalBus.Publish(ping); Assert.IsTrue(pong.IsAvailable(3.Seconds()), "No pong generated"); consumer.ShouldHaveReceivedMessage(pong.Message, 3.Seconds()); otherConsumer.ShouldHaveReceivedMessage(pong.Message, 1.Seconds()); }
public void A_response_should_be_published_if_no_reply_address_is_specified() { var ping = new PingMessage(); var otherConsumer = new TestMessageConsumer<PongMessage>(); RemoteBus.SubscribeInstance(otherConsumer); LocalBus.ShouldHaveRemoteSubscriptionFor<PongMessage>(); var consumer = new TestCorrelatedConsumer<PongMessage, Guid>(ping.CorrelationId); LocalBus.SubscribeInstance(consumer); var pong = new FutureMessage<PongMessage>(); RemoteBus.SubscribeHandler<PingMessage>(message => { pong.Set(new PongMessage(message.CorrelationId)); RemoteBus.Context().Respond(pong.Message); }); RemoteBus.ShouldHaveRemoteSubscriptionFor<PongMessage>(); LocalBus.ShouldHaveRemoteSubscriptionFor<PingMessage>(); LocalBus.Publish(ping); pong.IsAvailable(8.Seconds()).ShouldBeTrue("No pong generated"); consumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds()); otherConsumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds()); }
public void A_response_should_be_published_if_no_reply_address_is_specified() { var ping = new PingMessage(); var otherConsumer = new TestMessageConsumer <PongMessage>(); RemoteBus.SubscribeInstance(otherConsumer); LocalBus.ShouldHaveRemoteSubscriptionFor <PongMessage>(); var consumer = new TestCorrelatedConsumer <PongMessage, Guid>(ping.CorrelationId); LocalBus.SubscribeInstance(consumer); var pong = new FutureMessage <PongMessage>(); RemoteBus.SubscribeHandler <PingMessage>(message => { pong.Set(new PongMessage(message.CorrelationId)); RemoteBus.Context().Respond(pong.Message); }); RemoteBus.ShouldHaveRemoteSubscriptionFor <PongMessage>(); LocalBus.ShouldHaveRemoteSubscriptionFor <PingMessage>(); LocalBus.Publish(ping); pong.IsAvailable(8.Seconds()).ShouldBeTrue("No pong generated"); consumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds()); otherConsumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds()); }
public void A_response_should_be_published_if_no_reply_address_is_specified() { PingMessage ping = new PingMessage(); TestMessageConsumer<PongMessage> otherConsumer = new TestMessageConsumer<PongMessage>(); RemoteBus.Subscribe(otherConsumer); TestCorrelatedConsumer<PongMessage, Guid> consumer = new TestCorrelatedConsumer<PongMessage, Guid>(ping.CorrelationId); LocalBus.Subscribe(consumer); FutureMessage<PongMessage> pong = new FutureMessage<PongMessage>(); RemoteBus.Subscribe<PingMessage>(message => { pong.Set(new PongMessage(message.CorrelationId)); CurrentMessage.Respond(pong.Message); }); LocalBus.Publish(ping); Assert.IsTrue(pong.IsAvailable(3.Seconds()), "No pong generated"); consumer.ShouldHaveReceivedMessage(pong.Message, 3.Seconds()); otherConsumer.ShouldHaveReceivedMessage(pong.Message, 1.Seconds()); }
public void A_simple_bus_should_be_able_to_subscribe_and_publish() { TestMessageConsumer<PingMessage> consumer = new TestMessageConsumer<PingMessage>(); LocalBus.Subscribe(consumer); PingMessage message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, 500.Milliseconds()); }
public void It_should_be_received_by_one_subscribed_consumer_on_the_same_bus() { var consumer = new TestMessageConsumer<PingMessage>(); LocalBus.Subscribe(consumer); var message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); }
public void A_simple_bus_should_be_able_to_subscribe_and_publish() { var consumer = new TestMessageConsumer<PingMessage>(); LocalBus.SubscribeInstance(consumer); var message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, 8.Seconds()); }
public void It_should_be_received_by_one_subscribed_consumer() { TestMessageConsumer<PingMessage> consumer = new TestMessageConsumer<PingMessage>(); RemoteBus.SubscribeInstance(consumer); PingMessage message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); }
public void An_unfiltered_message_should_be_received() { var consumer = new TestMessageConsumer <PingMessage>(); _pipeline.Subscribe(consumer); var message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldHaveReceivedMessage(message); }
public void A_simple_bus_should_be_able_to_subscribe_and_publish() { TestMessageConsumer <PingMessage> consumer = new TestMessageConsumer <PingMessage>(); LocalBus.SubscribeInstance(consumer); PingMessage message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, 500.Milliseconds()); }
public void It_should_be_received_by_one_subscribed_message_handler() { TestMessageConsumer <PingMessage> messageConsumer = new TestMessageConsumer <PingMessage>(); RemoteBus.Subscribe <PingMessage>(messageConsumer.MessageHandler); PingMessage message = new PingMessage(); LocalBus.Publish(message); messageConsumer.ShouldHaveReceivedMessage(message, _timeout); }
public void It_should_be_received_by_one_subscribed_consumer_on_the_same_bus() { var consumer = new TestMessageConsumer <PingMessage>(); LocalBus.Subscribe(consumer); var message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); }
public void Should_accept_the_type_specified_with_context() { var consumer = new TestMessageConsumer<PingMessage>(); LocalBus.SubscribeInstance(consumer); var message = new PingMessage(); object unknownMessage = message; LocalBus.Publish(unknownMessage, typeof(PingMessage), x => x.SetRequestId("27")); consumer.ShouldHaveReceivedMessage(message, 8.Seconds()); }
public void Should_receive_the_proper_message() { var consumer = new TestMessageConsumer<PingMessage>(); LocalBus.SubscribeInstance(consumer); var message = new PingMessage(); object unknownMessage = message; LocalBus.Publish(unknownMessage); consumer.ShouldHaveReceivedMessage(message, 8.Seconds()); }
public void It_should_be_received_by_one_subscribed_consumer() { var consumer = new TestMessageConsumer <PingMessage>(); RemoteBus.SubscribeInstance(consumer); LocalBus.ShouldHaveSubscriptionFor <PingMessage>(); var message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); }
public void Should_accept_the_type_specified() { var consumer = new TestMessageConsumer <PingMessage>(); LocalBus.SubscribeInstance(consumer); var message = new PingMessage(); object unknownMessage = message; LocalBus.Endpoint.Send(unknownMessage, typeof(PingMessage)); consumer.ShouldHaveReceivedMessage(message, 8.Seconds()); }
public void It_should_be_received_by_multiple_subscribed_consumers() { TestMessageConsumer<PingMessage> consumer = new TestMessageConsumer<PingMessage>(); RemoteBus.Subscribe(consumer); TestMessageConsumer<PingMessage> messageConsumer = new TestMessageConsumer<PingMessage>(); RemoteBus.Subscribe<PingMessage>(messageConsumer.MessageHandler); PingMessage message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); messageConsumer.ShouldHaveReceivedMessage(message, _timeout); }
public void It_should_leave_the_message_in_the_queue_if_an_exception_is_thrown() { var consumer = new TestSelectiveConsumer<PingMessage>(x => false); RemoteBus.Subscribe(consumer); var realConsumer = new TestMessageConsumer<PingMessage>(); LocalBus.Subscribe(realConsumer); var message = new PingMessage(); LocalBus.Publish(message); realConsumer.ShouldHaveReceivedMessage(message, _timeout); consumer.ShouldNotHaveReceivedMessage(message, _timeout); }
public void It_should_be_received_by_multiple_subscribed_consumers() { var localConsumer = new TestMessageConsumer<PingMessage>(); LocalBus.Subscribe(localConsumer); var remoteConsumer = new TestMessageConsumer<PingMessage>(); RemoteBus.Subscribe(remoteConsumer); PingMessage message = new PingMessage(); LocalBus.Publish(message); localConsumer.ShouldHaveReceivedMessage(message, _timeout); remoteConsumer.ShouldHaveReceivedMessage(message, _timeout); }
public void It_should_be_received_by_one_subscribed_consumer() { var consumer = new TestMessageConsumer <PingMessage>(); RemoteBus.Subscribe(consumer); Thread.Sleep(5.Seconds()); var message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); }
public void Should_receive_the_proper_message() { var consumer = new TestMessageConsumer <PingMessage>(); LocalBus.SubscribeInstance(consumer); var message = new PingMessage(); object unknownMessage = message; LocalBus.Endpoint.Send(unknownMessage); consumer.ShouldHaveReceivedMessage(message, 8.Seconds()); }
public void Should_accept_the_type_specified_with_context() { var consumer = new TestMessageConsumer <PingMessage>(); LocalBus.SubscribeInstance(consumer); var message = new PingMessage(); object unknownMessage = message; LocalBus.Publish(unknownMessage, typeof(PingMessage), x => x.SetRequestId("27")); consumer.ShouldHaveReceivedMessage(message, 8.Seconds()); }
public void The_system_should_be_ready_to_use_before_getting_underway() { var consumer = new TestMessageConsumer <PingMessage>(); var unsubscribeAction = RemoteBus.SubscribeInstance(consumer); LocalBus.ShouldHaveRemoteSubscriptionFor <PingMessage>(); var message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, 8.Seconds()); unsubscribeAction(); }
public void A_message_should_fall_throuh_happy_filters() { var consumer = new TestMessageConsumer <PingMessage>(); _pipeline.Filter <PingMessage>(x => true); _pipeline.Subscribe(consumer); var message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldHaveReceivedMessage(message); PipelineViewer.Trace(_pipeline); }
public void An_object_filter_should_pass_the_message_if_allowed() { var consumer = new TestMessageConsumer <object>(); _pipeline.Filter <object>("Message Passer", x => true); _pipeline.Subscribe(consumer); var message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldHaveReceivedMessage(message); PipelineViewer.Trace(_pipeline); }
public void It_should_be_received_by_multiple_subscribed_consumers() { var localConsumer = new TestMessageConsumer <PingMessage>(); LocalBus.Subscribe(localConsumer); var remoteConsumer = new TestMessageConsumer <PingMessage>(); RemoteBus.Subscribe(remoteConsumer); PingMessage message = new PingMessage(); LocalBus.Publish(message); localConsumer.ShouldHaveReceivedMessage(message, _timeout); remoteConsumer.ShouldHaveReceivedMessage(message, _timeout); }
public void It_should_be_received_after_the_deferral_period_elapses() { TestMessageConsumer<PingMessage> consumer = new TestMessageConsumer<PingMessage>(); LocalBus.Subscribe(consumer); Stopwatch watch = Stopwatch.StartNew(); var message = new PingMessage(); LocalBus.Publish(new DeferMessage(_correlationId, 1.Seconds(), message)); consumer.ShouldHaveReceivedMessage(message, 3.Seconds()); watch.Stop(); Debug.WriteLine(string.Format("Timeout took {0}ms", watch.ElapsedMilliseconds)); }
public void The_system_should_be_ready_to_use_before_getting_underway() { var consumer = new TestMessageConsumer <PingMessage>(); var unsubscribeAction = RemoteBus.Subscribe(consumer); Thread.Sleep(1000); DumpPipelines(); var message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, 500.Milliseconds()); unsubscribeAction(); }
public void It_should_not_be_received_by_an_uninterested_consumer() { TestMessageConsumer <PingMessage> messageConsumer = new TestMessageConsumer <PingMessage>(); RemoteBus.Subscribe <PingMessage>(messageConsumer.MessageHandler, x => false); TestMessageConsumer <PingMessage> consumer = new TestMessageConsumer <PingMessage>(); RemoteBus.Subscribe(consumer); PingMessage message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); messageConsumer.ShouldNotHaveReceivedMessage(message, TimeSpan.FromSeconds(1)); }
public void It_should_leave_the_message_in_the_queue_if_an_exception_is_thrown() { var consumer = new TestSelectiveConsumer <PingMessage>(x => false); RemoteBus.Subscribe(consumer); var realConsumer = new TestMessageConsumer <PingMessage>(); LocalBus.Subscribe(realConsumer); var message = new PingMessage(); LocalBus.Publish(message); realConsumer.ShouldHaveReceivedMessage(message, _timeout); consumer.ShouldNotHaveReceivedMessage(message, _timeout); }
public void Echo_reply_should_work() { var echoConsumer = new TestMessageConsumer<PingMessage>(); RemoteBus.Subscribe(echoConsumer); var replyConsumer = new TestMessageConsumer<PongMessage>(); LocalBus.Subscribe(replyConsumer); var echoMessage = new PingMessage(); LocalBus.Publish(echoMessage); echoConsumer.ShouldHaveReceivedMessage(echoMessage, _timeout); PongMessage replyMessage = new PongMessage(echoMessage.CorrelationId); RemoteBus.Publish(replyMessage); replyConsumer.ShouldHaveReceivedMessage(replyMessage, _timeout); }
public void It_should_be_received_after_the_deferral_period_elapses() { TestMessageConsumer <PingMessage> consumer = new TestMessageConsumer <PingMessage>(); LocalBus.Subscribe(consumer); Stopwatch watch = Stopwatch.StartNew(); var message = new PingMessage(); LocalBus.Publish(new DeferMessage(_correlationId, 1.Seconds(), message)); consumer.ShouldHaveReceivedMessage(message, 3.Seconds()); watch.Stop(); Debug.WriteLine(string.Format("Timeout took {0}ms", watch.ElapsedMilliseconds)); }
public void Should_dispatch_an_interface_via_the_pipeline() { var pipeline = InboundPipelineConfigurator.CreateDefault(null); var consumer = new TestMessageConsumer <IComplaintAdded>(); pipeline.ConnectInstance(consumer); var user = new User("Chris", "*****@*****.**"); IComplaintAdded complaint = new ComplaintAdded(user, "No toilet paper", BusinessArea.Appearance) { Body = "There was no toilet paper in the stall, forcing me to use my treasured issue of .NET Developer magazine." }; pipeline.Dispatch(complaint); consumer.ShouldHaveReceivedMessage(complaint); }
public void It_should_not_rollback_a_send_if_an_exception_is_thrown() { var consumer = new TestMessageConsumer <PongMessage>(); LocalBus.Subscribe(consumer); var message = new PingMessage(); var response = new PongMessage(message.CorrelationId); RemoteBus.Subscribe <PingMessage>(m => { RemoteBus.Publish(response); throw new ApplicationException("Boing!"); }); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(response, _timeout); }
public void It_should_be_received_by_multiple_subscribed_consumers() { TestMessageConsumer <PingMessage> consumer = new TestMessageConsumer <PingMessage>(); RemoteBus.SubscribeInstance(consumer); TestMessageConsumer <PingMessage> messageConsumer = new TestMessageConsumer <PingMessage>(); RemoteBus.SubscribeHandler <PingMessage>(messageConsumer.MessageHandler); LocalBus.ShouldHaveSubscriptionFor <PingMessage>(); PingMessage message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); messageConsumer.ShouldHaveReceivedMessage(message, _timeout); }
public void A_filter_should_be_removable() { var consumer = new TestMessageConsumer<PingMessage>(); var f = _pipeline.Filter<PingMessage>(x => false); PipelineViewer.Trace(_pipeline); var message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldNotHaveReceivedMessage(message); f(); PipelineViewer.Trace(_pipeline); message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldHaveReceivedMessage(message); }
public void Should_dispatch_an_interface_via_the_pipeline() { var builder = MockRepository.GenerateMock<IObjectBuilder>(); var pipeline = MessagePipelineConfigurator.CreateDefault(builder, null); var consumer = new TestMessageConsumer<ComplaintAdded>(); var unsubscribeAction = pipeline.Subscribe(consumer); var user = new UserImpl("Chris", "*****@*****.**"); ComplaintAdded complaint = new ComplaintAddedImpl(user, "No toilet paper", BusinessArea.Appearance) { Body = "There was no toilet paper in the stall, forcing me to use my treasured issue of .NET Developer magazine." }; pipeline.Dispatch(complaint); PipelineViewer.Trace(pipeline); consumer.ShouldHaveReceivedMessage(complaint); }
public void The_batch_should_throw_an_exception_that_the_timeout_occurred() { _batchSize = 2; var timeoutConsumer = new TestMessageConsumer <BatchTimeout <IndividualBatchMessage, Guid> >(); RemoteBus.Subscribe(timeoutConsumer); var batchConsumer = new TestBatchConsumer <IndividualBatchMessage, Guid>(); RemoteBus.Subscribe(batchConsumer); Guid batchId = Guid.NewGuid(); IndividualBatchMessage message = new IndividualBatchMessage(batchId, _batchSize); LocalBus.Publish(message); timeoutConsumer.ShouldHaveReceivedMessage(new BatchTimeout <IndividualBatchMessage, Guid>(batchId), _timeout); batchConsumer.ShouldNotHaveCompletedBatch(TimeSpan.Zero); }
public void Should_dispatch_an_interface_via_the_pipeline() { var builder = MockRepository.GenerateMock <IObjectBuilder>(); var pipeline = MessagePipelineConfigurator.CreateDefault(builder, null); var consumer = new TestMessageConsumer <ComplaintAdded>(); var unsubscribeAction = pipeline.Subscribe(consumer); var user = new UserImpl("Chris", "*****@*****.**"); ComplaintAdded complaint = new ComplaintAddedImpl(user, "No toilet paper", BusinessArea.Appearance) { Body = "There was no toilet paper in the stall, forcing me to use my treasured issue of .NET Developer magazine." }; pipeline.Dispatch(complaint); PipelineViewer.Trace(pipeline); consumer.ShouldHaveReceivedMessage(complaint); }
public void A_filter_should_be_removable() { var consumer = new TestMessageConsumer <PingMessage>(); var f = _pipeline.Filter <PingMessage>(x => false); PipelineViewer.Trace(_pipeline); var message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldNotHaveReceivedMessage(message); f(); PipelineViewer.Trace(_pipeline); message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldHaveReceivedMessage(message); }
public void Echo_reply_should_work() { var echoConsumer = new TestMessageConsumer <PingMessage>(); RemoteBus.Subscribe(echoConsumer); var replyConsumer = new TestMessageConsumer <PongMessage>(); LocalBus.Subscribe(replyConsumer); var echoMessage = new PingMessage(); LocalBus.Publish(echoMessage); echoConsumer.ShouldHaveReceivedMessage(echoMessage, _timeout); PongMessage replyMessage = new PongMessage(echoMessage.CorrelationId); RemoteBus.Publish(replyMessage); replyConsumer.ShouldHaveReceivedMessage(replyMessage, _timeout); }
public void Should_accept_the_type_specified() { var consumer = new TestMessageConsumer<PingMessage>(); LocalBus.SubscribeInstance(consumer); var message = new PingMessage(); object unknownMessage = message; LocalBus.Endpoint.Send(unknownMessage, typeof(PingMessage)); consumer.ShouldHaveReceivedMessage(message, 8.Seconds()); }
public void A_message_should_fall_throuh_happy_filters() { var consumer = new TestMessageConsumer<PingMessage>(); _pipeline.Filter<PingMessage>(x => true); _pipeline.Subscribe(consumer); var message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldHaveReceivedMessage(message); PipelineViewer.Trace(_pipeline); }
public void An_object_filter_should_pass_the_message_if_allowed() { var consumer = new TestMessageConsumer<object>(); _pipeline.Filter<object>("Message Passer", x => true); _pipeline.Subscribe(consumer); var message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldHaveReceivedMessage(message); PipelineViewer.Trace(_pipeline); }
public void An_unfiltered_message_should_be_received() { var consumer = new TestMessageConsumer<PingMessage>(); _pipeline.Subscribe(consumer); var message = new PingMessage(); _pipeline.Dispatch(message); consumer.ShouldHaveReceivedMessage(message); }
public void It_should_be_received_by_one_subscribed_message_handler() { TestMessageConsumer<PingMessage> messageConsumer = new TestMessageConsumer<PingMessage>(); RemoteBus.SubscribeHandler<PingMessage>(messageConsumer.MessageHandler); LocalBus.ShouldHaveSubscriptionFor<PingMessage>(); PingMessage message = new PingMessage(); LocalBus.Publish(message); messageConsumer.ShouldHaveReceivedMessage(message, _timeout); }
public void It_should_not_be_received_by_an_uninterested_consumer() { TestMessageConsumer<PingMessage> messageConsumer = new TestMessageConsumer<PingMessage>(); RemoteBus.SubscribeHandler<PingMessage>(messageConsumer.MessageHandler, x => false); TestMessageConsumer<PingMessage> consumer = new TestMessageConsumer<PingMessage>(); RemoteBus.SubscribeInstance(consumer); PingMessage message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); messageConsumer.ShouldNotHaveReceivedMessage(message, TimeSpan.FromSeconds(1)); }
public void The_batch_should_throw_an_exception_that_the_timeout_occurred() { _batchSize = 2; var timeoutConsumer = new TestMessageConsumer<BatchTimeout<IndividualBatchMessage, Guid>>(); RemoteBus.Subscribe(timeoutConsumer); var batchConsumer = new TestBatchConsumer<IndividualBatchMessage, Guid>(); RemoteBus.Subscribe(batchConsumer); Guid batchId = Guid.NewGuid(); IndividualBatchMessage message = new IndividualBatchMessage(batchId, _batchSize); LocalBus.Publish(message); timeoutConsumer.ShouldHaveReceivedMessage(new BatchTimeout<IndividualBatchMessage, Guid>(batchId), _timeout); batchConsumer.ShouldNotHaveCompletedBatch(TimeSpan.Zero); }