public void When_A_Message_Is_Dispatched_It_Should_Reach_A_Handler() { _messagePump.Run(); //_should_dispatch_the_message_to_a_handler Assert.True(MyEventHandler.ShouldReceive(_event)); }
public void When_Publishing_An_Event_To_The_Processor() { _commandProcessor.Publish(_myEvent); //_should_publish_the_command_to_the_event_handlers Assert.True(MyEventHandler.ShouldReceive(_myEvent)); }
public void When_There_Are_Multiple_Subscribers() { _exception = Catch.Exception(() => _commandProcessor.Publish(_myEvent)); //_should_not_throw_an_exception Assert.Null(_exception); //_should_publish_the_command_to_the_first_event_handler Assert.True(MyEventHandler.ShouldReceive(_myEvent)); //_should_publish_the_command_to_the_second_event_handler Assert.True(MyOtherEventHandler.Shouldreceive(_myEvent)); }
public void When_Publishing_To_Multiple_Subscribers_Should_Aggregate_Exceptions() { _exception = Catch.Exception(() => _commandProcessor.Publish(_myEvent)); //_should_throw_an_aggregate_exception Assert.IsInstanceOf(typeof(AggregateException), _exception); //_should_have_an_inner_exception_from_the_handler Assert.IsInstanceOf(typeof(InvalidOperationException), ((AggregateException)_exception).InnerException); //_should_publish_the_command_to_the_first_event_handler Assert.True(MyEventHandler.ShouldReceive(_myEvent)); //_should_publish_the_command_to_the_second_event_handler Assert.True(MyOtherEventHandler.Shouldreceive(_myEvent)); }