コード例 #1
0
        public void RemoveConsumerBeforeSend()
        {
            var dispatcher = new BroadcastingDispatcher(provider.GetService <IApplicationContext>());

            dispatcher.AddHandler(targetMock1.Object);
            dispatcher.AddHandler(targetMock2.Object);
            dispatcher.AddHandler(targetMock3.Object);
            dispatcher.RemoveHandler(targetMock2.Object);
            dispatcher.Dispatch(messageMock.Object);
            targetMock1.Verify((h) => h.HandleMessage(messageMock.Object));
            targetMock2.Verify((h) => h.HandleMessage(messageMock.Object), Times.Never());
            targetMock3.Verify((h) => h.HandleMessage(messageMock.Object));
        }
コード例 #2
0
        public void RemoveConsumerBetweenSends()
        {
            var dispatcher = new BroadcastingDispatcher(provider);

            dispatcher.AddHandler(targetMock1.Object);
            dispatcher.AddHandler(targetMock2.Object);
            dispatcher.AddHandler(targetMock3.Object);
            dispatcher.Dispatch(messageMock.Object);
            dispatcher.RemoveHandler(targetMock2.Object);
            dispatcher.Dispatch(messageMock.Object);
            targetMock1.Verify((h) => h.HandleMessage(messageMock.Object), Times.Exactly(2));
            targetMock2.Verify((h) => h.HandleMessage(messageMock.Object), Times.Exactly(1));
            targetMock3.Verify((h) => h.HandleMessage(messageMock.Object), Times.Exactly(2));
        }