public void It_should_skip_when_mapped_method_is_static()
        {
            var aggregate = new IlligalStaticMethodTarget();
            var mapping = new ConventionBasedEventHandlerMappingStrategy();

            var handlers = mapping.GetEventHandlers(aggregate);

            handlers.Should().BeEmpty();
        }
        public void It_should_skip_when_mapped_method_does_not_have_a_parameter()
        {
            var aggregate = new NoParameterMethodTarget();
            var mapping = new ConventionBasedEventHandlerMappingStrategy();

            var handlers = mapping.GetEventHandlers(aggregate);

            handlers.Should().BeEmpty();
        }
        public void It_should_map_the_mapped_events()
        {
            var aggregate = new GoodTarget();
            var mapping = new ConventionBasedEventHandlerMappingStrategy();

            var handlers = mapping.GetEventHandlers(aggregate);

            handlers.Count().Should().Be(4);
            handlers.Should().OnlyHaveUniqueItems();
        }
Пример #4
0
        protected EntityMappedByConvention(AggregateRoot parent, Guid entityId)
            : base(parent, entityId)
        {
            var mapping = new ConventionBasedEventHandlerMappingStrategy();
            var handlers = mapping.GetEventHandlers(this);

            foreach(var directHandler in handlers)
            {
                var handler = new SourcedEventHandlerPredicate<SourcedEntityEvent>((e) => e.EntityId == this.EntityId,
                                                                                   directHandler);

                parent.RegisterHandler(handler);
            }
        }
        public void It_should_create_the_correct_event_handlers()
        {
            var aggregate = new GoodTarget();
            var mapping = new ConventionBasedEventHandlerMappingStrategy();

            var handlers = mapping.GetEventHandlers(aggregate);

            foreach (var handler in handlers)
            {
                handler.HandleEvent(new GoodTarget.PublicEvent());
                handler.HandleEvent(new GoodTarget.ProtectedEvent());
                handler.HandleEvent(new GoodTarget.InternalEvent());
                handler.HandleEvent(new GoodTarget.PrivateEvent());
            }

            aggregate.PublicEventHandlerInvokeCount.Should().Be(1);
            aggregate.ProtectedEventHandlerInvokeCount.Should().Be(1);
            aggregate.InternalEventHandlerInvokeCount.Should().Be(1);
            aggregate.PrivateEventHandlerInvokeCount.Should().Be(1);
        }
        public void It_should_skip_when_mapped_method_does_not_have_a_EventBaseType_as_parameter()
        {
            var aggregate = new NotAIEventSourceTarget();
            var mapping = new ConventionBasedEventHandlerMappingStrategy {EventBaseType = typeof (ISourcedEvent)};

            var handlers = mapping.GetEventHandlers(aggregate);

            handlers.Should().BeEmpty();
        }