コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }