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)); }
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)); }