Ejemplo n.º 1
0
        public void GivenAMessage_WhenAskedToProcess_ShouldTryToFindHandlersForMessageTypeHierarchy()
        {
            var expected = new[]
            {
                typeof(ICommandHandler <object>),
                typeof(ICommandHandler <SimpleCommandBase>),
                typeof(ICommandHandler <SimpleCommand>),
            };

            var result = new List <Type>();

            Resolver.ClearResolvers();
            Resolver.SetResolvers(
                type => null,
                type =>
            {
                result.Add(type);
                return(LocateAllCommandHandlers(type));
            });

            var processor = new CommandProcessor(new NullLogger());

            processor.Process(new SimpleCommand());

            CollectionAssert.AreEqual(expected, result);
        }
Ejemplo n.º 2
0
        public void GivenAMessage_WhenAskedToPublish_ShouldTryToFindHandlersForMessageTypeHierarchy()
        {
            var expected = new[]
            {
                typeof(IEventHandler <object>),
                typeof(IEventHandler <SimpleEventBase>),
                typeof(IEventHandler <SimpleEvent>),
                typeof(IEventHandler <IEventHandlingSucceededEvent <object> >),
                typeof(IEventHandler <IEventHandlingSucceededEvent <SimpleEventBase> >),
                typeof(IEventHandler <IEventHandlingSucceededEvent <SimpleEvent> >)
            };

            var result = new List <Type>();

            Resolver.ClearResolvers();
            Resolver.SetResolvers(
                type => null,
                type =>
            {
                result.Add(type);
                return(LocateAllEventHandlers(type));
            });

            _eventBus.Publish(new SimpleEvent());

            CollectionAssert.AreEqual(expected, result);
        }
Ejemplo n.º 3
0
        public void TearDown()
        {
            Conventions.SetFindAggregateTypeForEventType(null);

            Resolver.ClearResolvers();

            _documentStore.Dispose();
            _documentStore = null;
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public void TearDown()
 {
     Resolver.ClearResolvers();
 }
        public void TearDown()
        {
            ObjectComparisonResult.ThrowOnFail = false;

            Resolver.ClearResolvers();
        }