public void The_subscription_should_be_added_for_selective_consumers_that_are_interested() { var consumer = new ParticularConsumer(true); _pipeline.ConnectInstance(consumer); var message = new PingMessage(); _pipeline.Dispatch(message); Assert.AreEqual(message, consumer.Consumed); }
public void The_subscription_should_be_added_for_selective_consumers() { var consumer = new ParticularConsumer(false); _pipeline.ConnectInstance(consumer); var message = new PingMessage(); _pipeline.Dispatch(message); Assert.AreEqual(null, consumer.Consumed); }
public void A_selective_component_should_properly_handle_the_love() { ParticularConsumer consumer = MockRepository.GenerateMock <ParticularConsumer>(); _pipeline.ConnectConsumer <ParticularConsumer>(() => consumer); PipelineViewer.Trace(_pipeline); var message = new PingMessage(); consumer.Expect(x => x.Accept(message)).Return(true); consumer.Expect(x => x.Consume(message)); _pipeline.Dispatch(message); consumer.VerifyAllExpectations(); }
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); }