public void Publish <T>(T evt) where T : Event { var handlers = _evtHandlerStore.Get <T>(); if (handlers == null) { return; } foreach (var handler in handlers) { var handler1 = handler; Task.Run(() => handler1.Handle(evt)); } }
public void When_Handler_Is_Saved_And_Retrieve_It_Then_Handler_Is_Returned() { // ARRANGE InitializeFakeObjects(); var firstHandler = (new Mock <IHandle <AuthorizationRequestReceived> >()).Object; var secondHandler = (new Mock <IHandle <AuthorizationRequestReceived> >()).Object; _evtHandlerStore.Register(firstHandler); _evtHandlerStore.Register(secondHandler); // ACT var handlers = _evtHandlerStore.Get <AuthorizationRequestReceived>(); // ASSERTS Assert.NotNull(handlers); Assert.True(handlers.Count() == 2); }