public void Handle_WithNull_DoesNothing() { // Arrange var dispatcher = new TopicDispatcher(); // Act TestDelegate handle = () => dispatcher.Handle(subscriber, null); // Assert Assert.That(handle, Throws.Nothing); }
public void Handle_WithNoHandlerRegistered_DoesNothing() { // Arrange var dispatcher = new TopicDispatcher(); var message = new Topic(); // Act TestDelegate handle = () => dispatcher.Handle(subscriber, message); // Assert Assert.That(handle, Throws.Nothing); }
public void Handle_WithBaseClassHandlerRegistered_DoesNothing() { // Arrange var dispatcher = new TopicDispatcher(); dispatcher.Register(handler); var message = new SubTopic(); // Act dispatcher.Handle(subscriber, message); // Assert mockHandler.Verify(m => m.Handle(It.IsAny <Topic>()), Times.Never); }
public void Handle_WithAsyncHandlerRegistered_CallsHandler() { // Arrange var dispatcher = new TopicDispatcher(); dispatcher.Register(asyncHandler); var message = new Topic(); // Act dispatcher.Handle(subscriber, message); // Assert mockAsyncHandler.Verify(m => m.Handle(It.IsIn(message)), Times.Once); }
public void Handle_WithHandlerDelegateRegistered_CallsHandler() { // Arrange var handled = false; var dispatcher = new TopicDispatcher(); var message = new Topic(); dispatcher.Register <Topic>(e => { handled = true; }); // Act dispatcher.Handle(subscriber, message); // Assert Assert.That(handled, Is.True); }
public void Handle_WithAsyncHandlerDelegateRegistered_CallsHandler() { // Arrange var handled = false; var dispatcher = new TopicDispatcher(); var message = new Topic(); var wait = new ManualResetEvent(false); dispatcher.Register <Topic>(e => Task.Run(() => { handled = true; wait.Set(); })); // Act dispatcher.Handle(subscriber, message); wait.WaitOne(); // Assert Assert.That(handled, Is.True); }