diff --git a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AsyncActionEventHandler.cs b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/ActionEventHandler.cs similarity index 81% rename from src/Volo.Abp.EventBus/Volo/Abp/EventBus/AsyncActionEventHandler.cs rename to src/Volo.Abp.EventBus/Volo/Abp/EventBus/ActionEventHandler.cs index fb566f8775..69e834f5b0 100644 --- a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AsyncActionEventHandler.cs +++ b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/ActionEventHandler.cs @@ -8,7 +8,7 @@ namespace Volo.Abp.EventBus /// This event handler is an adapter to be able to use an action as implementation. /// /// Event type - internal class AsyncActionEventHandler : + internal class ActionEventHandler : IAsyncEventHandler, ITransientDependency { @@ -18,10 +18,10 @@ namespace Volo.Abp.EventBus public Func Action { get; } /// - /// Creates a new instance of . + /// Creates a new instance of . /// /// Action to handle the event - public AsyncActionEventHandler(Func handler) + public ActionEventHandler(Func handler) { Action = handler; } diff --git a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs index 20b29f2aed..629946bf89 100644 --- a/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs +++ b/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBus.cs @@ -66,7 +66,7 @@ namespace Volo.Abp.EventBus /// public IDisposable Register(Func action) where TEvent : class { - return Register(typeof(TEvent), new AsyncActionEventHandler(action)); + return Register(typeof(TEvent), new ActionEventHandler(action)); } /// @@ -121,7 +121,7 @@ namespace Volo.Abp.EventBus return false; } - var actionHandler = singleInstanceFactory.HandlerInstance as AsyncActionEventHandler; + var actionHandler = singleInstanceFactory.HandlerInstance as ActionEventHandler; if (actionHandler == null) { return false; diff --git a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_DI_Services_Test.cs b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_DI_Services_Test.cs index 85dc53a1bc..0567522d68 100644 --- a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_DI_Services_Test.cs +++ b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_DI_Services_Test.cs @@ -15,7 +15,6 @@ namespace Volo.Abp.EventBus await EventBus.TriggerAsync(new MySimpleEventData(4)); GetRequiredService().TotalData.ShouldBe(10); - GetRequiredService().TotalData.ShouldBe(10); } } } diff --git a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs index 2095c7800f..12585902b8 100644 --- a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs +++ b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventBus_MultipleHandle_Test.cs @@ -16,18 +16,10 @@ namespace Volo.Abp.EventBus EventBus.Register>(handler); EventBus.Register>(handler); - var asyncHandler = new MyAsyncEventHandler(); - - EventBus.Register>(asyncHandler); - EventBus.Register>(asyncHandler); - await EventBus.TriggerAsync(new EntityCreatedEventData(new MyEntity())); handler.EntityCreatedEventCount.ShouldBe(1); handler.EntityChangedEventCount.ShouldBe(1); - - asyncHandler.EntityCreatedEventCount.ShouldBe(1); - asyncHandler.EntityChangedEventCount.ShouldBe(1); } public class MyEntity : Entity @@ -54,25 +46,5 @@ namespace Volo.Abp.EventBus return Task.CompletedTask; } } - - public class MyAsyncEventHandler : - IAsyncEventHandler>, - IAsyncEventHandler> - { - public int EntityChangedEventCount { get; set; } - public int EntityCreatedEventCount { get; set; } - - public Task HandleEventAsync(EntityChangedEventData eventData) - { - EntityChangedEventCount++; - return Task.FromResult(0); - } - - public Task HandleEventAsync(EntityCreatedEventData eventData) - { - EntityCreatedEventCount++; - return Task.FromResult(0); - } - } } } diff --git a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleAsyncEventDataHandler.cs b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleAsyncEventDataHandler.cs deleted file mode 100644 index b8f6802fe6..0000000000 --- a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleAsyncEventDataHandler.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; - -namespace Volo.Abp.EventBus -{ - public class MySimpleAsyncEventDataHandler : IAsyncEventHandler, ISingletonDependency - { - public int TotalData { get; private set; } - - public Task HandleEventAsync(MySimpleEventData eventData) - { - TotalData += eventData.Value; - return Task.CompletedTask; - } - } -} \ No newline at end of file diff --git a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleTransientAsyncEventHandler.cs b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleTransientAsyncEventHandler.cs deleted file mode 100644 index 755df57faa..0000000000 --- a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleTransientAsyncEventHandler.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace Volo.Abp.EventBus -{ - public class MySimpleTransientAsyncEventHandler : IAsyncEventHandler, IDisposable - { - public static int HandleCount { get; set; } - - public static int DisposeCount { get; set; } - - public Task HandleEventAsync(MySimpleEventData eventData) - { - ++HandleCount; - return Task.FromResult(0); - } - - public void Dispose() - { - ++DisposeCount; - } - } -} \ No newline at end of file diff --git a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/TransientDisposableEventHandlerTest.cs b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/TransientDisposableEventHandlerTest.cs index 1756960dc9..3250128ea8 100644 --- a/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/TransientDisposableEventHandlerTest.cs +++ b/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/TransientDisposableEventHandlerTest.cs @@ -9,7 +9,6 @@ namespace Volo.Abp.EventBus public async Task Should_Call_Handler_AndDispose() { EventBus.Register(); - EventBus.Register(); await EventBus.TriggerAsync(new MySimpleEventData(1)); await EventBus.TriggerAsync(new MySimpleEventData(2)); @@ -17,9 +16,6 @@ namespace Volo.Abp.EventBus Assert.Equal(3, MySimpleTransientEventHandler.HandleCount); Assert.Equal(3, MySimpleTransientEventHandler.DisposeCount); - - Assert.Equal(3, MySimpleTransientAsyncEventHandler.HandleCount); - Assert.Equal(3, MySimpleTransientAsyncEventHandler.DisposeCount); } } } \ No newline at end of file