简体   繁体   中英

Akka.net testing actor using Context.DI()

I think this should be an "easy" one. I'm trying to test the behavior of an actor that performs a child actor creation when receiving a message. I'm using Context.DI().Props<ChildActor>() to create it and that's fine however there is an exception being thrown when I try to run the tests:

Cause: System.NullReferenceException: Object reference not set to an instance of an object.
   at Akka.DI.Core.DIActorContextAdapter.Props[TActor]()

And I have installed the Akka.TestKit, the Akka.DI.TestKit, etc. Is there anything I need to configure/set in my test to "mock" the Context.DI()?

Thanks!

Akka.DI.TestKit is used to test custom IoC container plugins (like Autofac, NInject etc.) for compatibility with Akka. They are not used for testing custom code.

If you want to mock Context.DI() you probably need to supply container and register your mocks in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM