public void A_response_should_be_sent_directly_if_a_reply_address_is_specified() { var ping = new PingMessage(); var otherConsumer = new TestMessageConsumer <PongMessage>(); RemoteBus.SubscribeInstance(otherConsumer); 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 <PongMessage>(); LocalBus.ShouldHaveRemoteSubscriptionFor <PingMessage>(); LocalBus.Publish(ping, context => context.SendResponseTo(LocalBus)); Assert.IsTrue(pong.IsAvailable(8.Seconds()), "No pong generated"); consumer.ShouldHaveReceivedMessage(pong.Message, 8.Seconds()); otherConsumer.ShouldNotHaveReceivedMessage(pong.Message, 1.Seconds()); }
public void A_consumer_is_subscribed_to_a_message() { Consumer = new ConsumerOf <SimpleMessage>(); RemoteBus.SubscribeInstance(Consumer); LocalBus.ShouldHaveSubscriptionFor <SimpleMessage>(); }
public void a_rat_is_sent_to_a_hungry_cat() { rat_id = CombGuid.Generate(); received_rat = new Future <Rat>(); cat = new ConsumerOf <Rat>(a_large_rat_actually => { Console.WriteLine("Miaooo!!!"); Console.WriteLine(a_large_rat_actually.Sound + "!!!"); Console.WriteLine("Cat: chase! ..."); Console.WriteLine("*silence*"); Console.WriteLine("Cat: *Crunch chrunch*"); received_rat.Complete(a_large_rat_actually); }); cat_nap_unsubscribes = RemoteBus.SubscribeInstance(cat); // we need to make sure this bus is up before sending to it RemoteBus.Endpoint.InboundTransport.Receive(ctx => c => { }, 4.Seconds()); LocalBus.GetEndpoint(RemoteUri).Send <Rat>(new { Sound = "Eeeek", CorrelationId = rat_id }); }
public void A_pong_service() { PingService = new ConsumerOf <Ping>(ping => { // Response with a pong to the ping RemoteBus.Context().Respond(new Pong(ping.CorrelationId)); }); RemoteBus.SubscribeInstance(PingService); }
public void Should_have_received_b_on_an_instance() { var consumer = new ConsumerOfAAndB(); RemoteBus.SubscribeInstance(consumer); var message = new B(); LocalBus.Publish(message); consumer.ConsumerB.ShouldHaveReceivedMessage(message, 8.Seconds()); }
public void Publishing_to_a_remote_subscriber() { Consumer = new ConsumerOf <SimpleMessage>(); _unsubscribeAction = RemoteBus.SubscribeInstance(Consumer); RemoteBus.ShouldHaveSubscriptionFor <SimpleMessage>(); LocalBus.ShouldHaveSubscriptionFor <SimpleMessage>(); _message = new SimpleMessage(); LocalBus.Publish(_message); }
public void It_should_be_received_by_an_interested_correlated_consumer() { var message = new PingMessage(); var consumer = new TestCorrelatedConsumer <PingMessage, Guid>(message.CorrelationId); RemoteBus.SubscribeInstance(consumer); LocalBus.ShouldHaveSubscriptionFor <PingMessage>(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); }
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 It_should_not_be_received_by_an_uninterested_correlated_consumer() { TestCorrelatedConsumer <PingMessage, Guid> consumer = new TestCorrelatedConsumer <PingMessage, Guid>(Guid.NewGuid()); RemoteBus.SubscribeInstance(consumer); LocalBus.ShouldHaveSubscriptionFor <PingMessage>(); PingMessage message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldNotHaveReceivedMessage(message, _timeout); }
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 It_should_not_be_received_by_an_uninterested_consumer() { var messageConsumer = new TestMessageConsumer <PingMessage>(); RemoteBus.SubscribeHandler <PingMessage>(messageConsumer.MessageHandler, x => false); var consumer = new TestMessageConsumer <PingMessage>(); RemoteBus.SubscribeInstance(consumer); LocalBus.ShouldHaveSubscriptionFor <PingMessage>(); var message = new PingMessage(); LocalBus.Publish(message); consumer.ShouldHaveReceivedMessage(message, _timeout); messageConsumer.ShouldNotHaveReceivedMessage(message, TimeSpan.FromSeconds(1)); }
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); }