public void When_There_Are_Multiple_Subscribers_Async() { _exception = Catch.Exception(() => AsyncContext.Run(async() => await _commandProcessor.PublishAsync(_myEvent))); //_should_not_throw_an_exception Assert.Null(_exception); //_should_publish_the_command_to_the_first_event_handler Assert.True(MyEventHandlerAsync.ShouldReceive(_myEvent)); //_should_publish_the_command_to_the_second_event_handler Assert.True(MyOtherEventHandlerAsync.ShouldReceive(_myEvent)); }
public void When_Publishing_To_Multiple_Subscribers_Should_Aggregate_Exceptions_Async() { _exception = Catch.Exception(() => AsyncContext.Run(async() => await _commandProcessor.PublishAsync(_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(MyEventHandlerAsync.ShouldReceive(_myEvent)); //_should_publish_the_command_to_the_second_event_handler Assert.True(MyOtherEventHandlerAsync.ShouldReceive(_myEvent)); }