Akka.Hosting icon indicating copy to clipboard operation
Akka.Hosting copied to clipboard

Akka.Hosting.TestKit: `TestActor` is no longer the implicit sender

Open Aaronontheweb opened this issue 2 years ago • 3 comments

Version Information Version of Akka.NET? 1.0.3 Which Akka.NET Modules? Akka.Hosting.TestKit

Describe the bug

 foreach (var i in Enumerable.Range(0, 2))
        {
            var update1 = Dsl.Update(CounterKey, GCounter.Empty, WriteLocal.Instance,
                g => g.Increment(selfAddress));
            replicator.Tell(update1);
            UpdateSuccess success1 = ExpectMsg<UpdateSuccess>();
        }

Fails and UpdateSuccess is a DeadLetter - this is because ActorRefs.NoSender is the sender.

Expected behavior

TestActor should be the implicit sender, just like in the normal testkit.

Actual behavior

There is no implicit sender.

Workaround

Can explicitly specify the TestActor as the sender.

 foreach (var i in Enumerable.Range(0, 2))
        {
            var update1 = Dsl.Update(CounterKey, GCounter.Empty, WriteLocal.Instance,
                g => g.Increment(selfAddress));
            replicator.Tell(update1, TestActor);
            UpdateSuccess success1 = ExpectMsg<UpdateSuccess>();
        }

Aaronontheweb avatar Feb 21 '23 17:02 Aaronontheweb

It would be nice if this can be fixed. We are currently migrating to Akka.Hosting in this is one of the little roadblocks as we have to touch a lot of places for this workaround.

Other than that Akka.Hosting is a great addition, it makes a lot of custom code unnecessary. We had our own system of registering root actors in .Net DI, had our own Testkit with DI support etc etc.

gunters63 avatar Jul 29 '23 03:07 gunters63