Пример #1
0
        public void GivenAMessageThatWillFailHandling_WhenAskedToPublish_ShouldAllowRetryableExceptionsToPropagate()
        {
            Conventions.SetRetryableEventHandlingExceptionFilter((o, e) => true);
            var failingEventHandler = new FailingEventHandler();

            Resolver.ClearResolvers();
            Resolver.SetResolvers(
                type => null,
                type => new object[] { failingEventHandler }.Where(x => type.IsAssignableFrom(x.GetType())));

            var eventThatWillFailToBeHandled = new SimpleEvent();
            var exception = Assert.Throws <TargetInvocationException>(() => _eventBus.Publish(eventThatWillFailToBeHandled));

            CollectionAssert.AreEqual(
                new[]
            {
                typeof(SimpleEvent)
            },
                failingEventHandler.TargetsCalled);
        }
Пример #2
0
        public void GivenAMessageThatWillFailHandling_WhenAskedToPublish_ShouldGenerateFailedHandlingMessage()
        {
            var failingEventHandler = new FailingEventHandler();

            Resolver.ClearResolvers();
            Resolver.SetResolvers(
                type => null,
                type => new object[] { failingEventHandler }.Where(x => type.IsAssignableFrom(x.GetType())));

            var eventThatWillFailToBeHandled = new SimpleEvent();

            _eventBus.Publish(eventThatWillFailToBeHandled);

            CollectionAssert.AreEqual(
                new[]
            {
                typeof(SimpleEvent),
                typeof(IEventHandlingFailedEvent <SimpleEvent>)
            },
                failingEventHandler.TargetsCalled);
        }