public bool Visit <TMessage>(IndiscriminantConsumer <TMessage> obj) where TMessage : class { Trace.WriteLine("IndiscriminantConsumer<TMessage> - " + typeof(TMessage)); return(true); }
public void The_pipeline_should_have_insertable_items() { // two consumers, one for each type of message var pingConsumer = new IndiscriminantConsumer <PingMessage>(); var pongConsumer = new IndiscriminantConsumer <PongMessage>(); UnsubscribeAction pingToken = _pipeline.ConnectInstance(pingConsumer); UnsubscribeAction pongToken = _pipeline.ConnectInstance(pongConsumer); PipelineViewer.Trace(_pipeline); var pingMessage = new PingMessage(); var pongMessage = new PongMessage(); _pipeline.Dispatch(pingMessage, accept => true); _pipeline.Dispatch(pongMessage, accept => true); Assert.AreEqual(pingMessage, pingConsumer.Consumed); Assert.AreEqual(pongMessage, pongConsumer.Consumed); pingToken(); pongToken(); PipelineViewer.Trace(_pipeline); }
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_wrong_type_of_message_should_not_blow_up_the_test() { var consumer = new IndiscriminantConsumer <PingMessage>(); _pipeline.ConnectInstance(consumer); var message = new PongMessage(); _pipeline.Dispatch(message); Assert.AreEqual(null, consumer.Consumed); }
public void The_subscriptions_should_be_a_separate_concern_from_the_pipeline() { var consumer = new IndiscriminantConsumer <PingMessage>(); _pipeline.ConnectInstance(consumer); var message = new PingMessage(); _pipeline.Dispatch(message, x => true); Assert.AreEqual(message, consumer.Consumed); }
public void The_appropriate_handler_should_be_added() { var consumer = new IndiscriminantConsumer <PingMessage>(); _pipeline.ConnectInstance(consumer); var message = new PingMessage(); _pipeline.Dispatch(message, x => true); Assert.AreEqual(message, consumer.Consumed); }
public void When_somebody_gets_the_message_it_should_be_accepted() { var consumer = new IndiscriminantConsumer <PingMessage>(); _pipeline.ConnectInstance(consumer); var message = new PingMessage(); bool accepted = false; _pipeline.Dispatch(message, x => accepted = true); Assert.IsTrue(accepted); }
public void The_subscription_should_be_added() { var consumer = new IndiscriminantConsumer <PingMessage>(); Stopwatch firstTime = Stopwatch.StartNew(); _pipeline.ConnectInstance(consumer); firstTime.Stop(); var message = new PingMessage(); _pipeline.Dispatch(message); Assert.AreEqual(message, consumer.Consumed); }
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); }
public bool Visit(IndiscriminantConsumer <PingMessage> obj) { Trace.WriteLine("IndiscriminantConsumer<PingMessage>"); return(true); }