public void It_should_not_handle_event_when_there_needs_to_be_an_exact_match_and_event_types_are_derived() { var aggregate = new EventMappedExactOnMethodWithDerivedEventTypeTarget(); var mapping = new ExpressionBasedEventHandlerMappingStrategy(); var handlers = mapping.GetEventHandlers(aggregate); foreach (var handler in handlers) handler.HandleEvent(new EventMappedExactOnMethodWithDerivedEventTypeTarget.DerivedEvent()).Should().BeFalse(); }
public void It_should_map_the_mapped_events() { var aggregate = new GoodTarget(); var mapping = new ExpressionBasedEventHandlerMappingStrategy(); var handlers = mapping.GetEventHandlers(aggregate); handlers.Count().Should().Be(4); handlers.Should().OnlyHaveUniqueItems(); }
public void It_should_not_handle_event_when_there_is_a_mapping_inheritance_type_mismatch() { var aggregate = new MismatchOnEventTypeTarget(); var mapping = new ExpressionBasedEventHandlerMappingStrategy(); var handlers = mapping.GetEventHandlers(aggregate); foreach (var handler in handlers) handler.HandleEvent(new MismatchOnEventTypeTarget.BaseEvent()).Should().BeFalse(); }
public void It_should_create_the_correct_event_handlers() { var aggregate = new GoodTarget(); var mapping = new ExpressionBasedEventHandlerMappingStrategy(); 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); }