public void The_pipeline_should_be_happy() { var consumer = new IndiscriminantConsumer <PingMessage>(); _pipeline.ConnectInstance(consumer); _pipeline.Dispatch(new PingMessage()); Assert.IsNotNull(consumer.Consumed); }
public void The_appropriate_handler_should_be_added() { IndiscriminantConsumer <PingMessage> consumer = new IndiscriminantConsumer <PingMessage>(); _pipeline.ConnectInstance(consumer); PingMessage message = new PingMessage(); _pipeline.Dispatch(message, x => true); Assert.AreEqual(message, consumer.Consumed); }
/// <summary> /// Dispatch a message through the pipeline /// </summary> /// <param name="pipeline">The pipeline instance</param> /// <param name="message">The message to dispatch</param> public static bool Dispatch <T>(this IInboundMessagePipeline pipeline, T message) where T : class { return(pipeline.Dispatch(message, x => true)); }
public void A_bunch_of_mixed_subscriber_types_should_work() { var consumer = new IndiscriminantConsumer <PingMessage>(); var consumerYes = new ParticularConsumer(true); var consumerNo = new ParticularConsumer(false); Stopwatch firstTime = Stopwatch.StartNew(); var unsubscribeToken = _pipeline.ConnectInstance(consumer); firstTime.Stop(); Stopwatch secondTime = Stopwatch.StartNew(); unsubscribeToken += _pipeline.ConnectInstance(consumerYes); secondTime.Stop(); unsubscribeToken += _pipeline.ConnectInstance(consumerNo); Trace.WriteLine(string.Format("First time: {0}, Second Time: {1}", firstTime.Elapsed, secondTime.Elapsed)); PipelineViewer.Trace(_pipeline); var message = new PingMessage(); _pipeline.Dispatch(message); Assert.AreEqual(message, consumer.Consumed); Assert.AreEqual(message, consumerYes.Consumed); Assert.AreEqual(null, consumerNo.Consumed); unsubscribeToken(); var nextMessage = new PingMessage(); _pipeline.Dispatch(nextMessage); Assert.AreEqual(message, consumer.Consumed); Assert.AreEqual(message, consumerYes.Consumed); }