Ejemplo n.º 1
0
        public void for_correlated_subscriptions_but_not_when_another_exists()
        {
            Guid pongGuid = Guid.NewGuid();

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

            var consumer      = new TestCorrelatedConsumer <PongMessage, Guid>(pongGuid);
            var otherConsumer = new TestCorrelatedConsumer <PongMessage, Guid>(pongGuid);
            var remove        = _pipeline.ConnectInstance(consumer);
            var removeOther   = _pipeline.ConnectInstance(otherConsumer);

            remove();
            _subscriptionEvent.VerifyAllExpectations();
            _unsubscribe.AssertWasNotCalled(x => x());


            _unsubscribe.BackToRecord();
            _unsubscribe.Replay();

            removeOther();
            _unsubscribe.AssertWasCalled(x => x());
        }
Ejemplo n.º 2
0
        public void for_batch_subscriptions_but_not_when_another_exists()
        {
            _subscriptionEvent.Expect(x => x.SubscribedTo <IndividualBatchMessage>()).Repeat.Twice().Return(() =>
            {
                _unsubscribe();
                return(true);
            });

            var consumer = new TestBatchConsumer <IndividualBatchMessage, Guid>();
            var token    = _pipeline.Subscribe(consumer);

            var consumerB = new TestBatchConsumer <IndividualBatchMessage, Guid>();
            var tokenB    = _pipeline.Subscribe(consumerB);

            token();

            _subscriptionEvent.VerifyAllExpectations();
            _unsubscribe.AssertWasNotCalled(x => x());
        }