You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 7, 2020. It is now read-only.
public class EventHandlerTests
{
[Fact]
public void should_work()
{
var resolver = IocBuilder.New.UseAutofacContainerBuilder()
.UseStoveWithNullables(typeof(FakeBootstrapper)).UseStoveEventBus()
.RegisterServices(s =>
{
s.RegisterType<FakeBootstrapper>();
s.RegisterType<FakeSendToImageProcessorEventHandler>();
s.RegisterType<FakeVisualMappingCompletedEventHandler>();
})
.CreateResolver();
var eventBus = resolver.Resolve<IEventBus>();
eventBus.Register(typeof(VisualMappingCompletedEvent), new IocHandlerFactory(resolver, typeof(FakeSendToImageProcessorEventHandler)));
eventBus.Register(typeof(VisualMappingCompletedEvent), new IocHandlerFactory(resolver, typeof(FakeVisualMappingCompletedEventHandler)));
eventBus.Publish<VisualMappingCompletedEvent>(new VisualMappingCompletedEvent(), new Headers());
}
}
public class FakeSendToImageProcessorEventHandler : EventHandlerBase, IEventHandler<VisualMappingCompletedEvent>, ITransientDependency
{
static int a ;
public void Handle(VisualMappingCompletedEvent @event, Headers headers)
{
a++;
}
}
public class FakeVisualMappingCompletedEventHandler : EventHandlerBase, IEventHandler<VisualMappingCompletedEvent>, ITransientDependency
{
static int b;
public void Handle(VisualMappingCompletedEvent @event, Headers headers)
{
b++;
}
}
public class FakeBootstrapper : StoveBootstrapper
{
}
In this case you will see a = 2, b = 2
The text was updated successfully, but these errors were encountered:
CanerPatir
changed the title
Domain event handlers are fired multiple times in case of register multiple handlers for the same domain event.
Domain event handlers are fired multiple times in case of registering multiple handlers for the same domain event.
Jun 28, 2018
test case like following
In this case you will see a = 2, b = 2
The text was updated successfully, but these errors were encountered: