forked from akkadotnet/Akka.Hosting
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0119721
commit aa0f067
Showing
1 changed file
with
50 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Akka.Hosting.TestKit.Tests; | ||
|
||
public class Bugfix458Spec : TestKit | ||
{ | ||
private class EchoActor : ReceiveActor | ||
{ | ||
public EchoActor() | ||
{ | ||
ReceiveAny(msg => Sender.Tell(msg)); | ||
} | ||
} | ||
|
||
protected override void ConfigureAkka(AkkaConfigurationBuilder builder, IServiceProvider provider) | ||
{ | ||
builder.WithActors((system, registry, resolver) => | ||
{ | ||
var echoActor = system.ActorOf<EchoActor>("echo"); | ||
registry.Register<EchoActor>(echoActor); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void Bugfix458_should_resolve_TestActor_in_SynchronousCode() | ||
{ | ||
var echo = ActorRegistry.Get<EchoActor>(); | ||
echo.Tell("hello"); | ||
ExpectMsg("hello"); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1)] | ||
[InlineData(2)] | ||
[InlineData(3)] | ||
[InlineData(4)] | ||
[InlineData(5)] | ||
[InlineData(6)] | ||
[InlineData(7)] | ||
public async Task Bugfix458_should_resolve_TestActor_in_AsynchronousCode(int _) | ||
{ | ||
var echo = await ActorRegistry.GetAsync<EchoActor>(); | ||
echo.Tell("hello"); | ||
await ExpectMsgAsync("hello"); | ||
} | ||
} |