public void Publish() { var bus = new DictionaryMessageBus(); var handler = new Mock<TestListener>(); string data = "asdf"; bus.Subscribe(handler.Object); TestUtils.AssertArgumentException(() => bus.PublishSpecific<object>(null)); bus.PublishSpecific(data); handler.Verify(h => h.Listen1(data), Times.Once()); }
public void Publish_MultiSub_RunOnce() { var bus = new DictionaryMessageBus(); var handler = new Mock<TestListener>(); string data = "asdf"; bus.Subscribe(handler.Object); bus.Subscribe(handler.Object); bus.PublishSpecific(data); handler.Verify(h => h.Listen1(data), Times.Once()); }
public void Unsubscribe() { var bus = new DictionaryMessageBus(); var handler = new Mock<TestListener>(); string data = "asdf"; bus.Subscribe(handler.Object); bus.Unsubscribe(handler.Object); TestUtils.AssertArgumentException(() => bus.Unsubscribe(null)); bus.PublishSpecific(data); handler.Verify(h => h.Listen1(data), Times.Never(), "Handler called after unsubscribe"); }
public void Publish_NoSubscibers() { var bus = new DictionaryMessageBus(); bus.PublishSpecific(new object()); }