diff --git a/src/Akka.Hosting.TestKit.Tests/Bugfix458Spec.cs b/src/Akka.Hosting.TestKit.Tests/Bugfix458Spec.cs new file mode 100644 index 00000000..6133ac90 --- /dev/null +++ b/src/Akka.Hosting.TestKit.Tests/Bugfix458Spec.cs @@ -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("echo"); + registry.Register(echoActor); + }); + } + + [Fact] + public void Bugfix458_should_resolve_TestActor_in_SynchronousCode() + { + var echo = ActorRegistry.Get(); + 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(); + echo.Tell("hello"); + await ExpectMsgAsync("hello"); + } +} \ No newline at end of file