-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support a handler to implement both
Local
and Distribute
.
Resolve #19484
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/LocalAndDistributeEventHandlerRegister_Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Options; | ||
using Shouldly; | ||
using Volo.Abp.DependencyInjection; | ||
using Volo.Abp.EventBus.Distributed; | ||
using Volo.Abp.EventBus.Local; | ||
using Xunit; | ||
|
||
namespace Volo.Abp.EventBus; | ||
|
||
public class LocalAndDistributeEventHandlerRegister_Tests : EventBusTestBase | ||
{ | ||
[Fact] | ||
public void Should_Register_Both_Local_And_Distribute() | ||
{ | ||
var localOptions = GetRequiredService<IOptions<AbpLocalEventBusOptions>>(); | ||
var distributedOptions = GetRequiredService<IOptions<AbpDistributedEventBusOptions>>(); | ||
|
||
localOptions.Value.Handlers.ShouldContain(x => x == typeof(MyEventHandle)); | ||
distributedOptions.Value.Handlers.ShouldContain(x => x == typeof(MyEventHandle)); | ||
} | ||
|
||
class MyEventDate | ||
{ | ||
|
||
} | ||
|
||
class MyEventHandle : ILocalEventHandler<MyEventDate>, IDistributedEventHandler<MyEventDate>, ITransientDependency | ||
{ | ||
Task ILocalEventHandler<MyEventDate>.HandleEventAsync(MyEventDate eventData) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
Task IDistributedEventHandler<MyEventDate>.HandleEventAsync(MyEventDate eventData) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |