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);
        }
Exemplo n.º 2
0
        public void for_correlated_subscriptions()
        {
            Guid pongGuid = Guid.NewGuid();

            _subscriptionEvent.Expect(x => x.SubscribedTo <PongMessage, Guid>(pongGuid)).Return(() =>
            {
                _unsubscribe();
                return(true);
            });

            var consumer = new TestCorrelatedConsumer <PongMessage, Guid>(pongGuid);

            _pipeline.ConnectInstance(consumer);

            _subscriptionEvent.VerifyAllExpectations();
        }
Exemplo n.º 3
0
        public void The_pipeline_should_be_happy()
        {
            var consumer = new IndiscriminantConsumer <PingMessage>();

            _pipeline.ConnectInstance(consumer);

            _pipeline.Dispatch(new PingMessage());

            Assert.IsNotNull(consumer.Consumed);
        }
Exemplo n.º 4
0
        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);
        }