Unit testing the Actors
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 378
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
I wrote an application that uses dapr Actors in dotNet core.
I'm trying to unit test the actors and I currently see no way to do it.
I used ActorHost.CreateForTest method to create the host and set the ID, however when my Actor gets the state it fails with the InvalidOperationException and the following message:
`The actor was initialized without a state provider, and so cannot interact with state. If this is inside a unit test, replace Actor.StateProvider with a mock.`
As far as I see StateProvider property is available on the ActorHost but it's internal and can't be set from the outside.
Also, in my actor I use the Reminders feature, and I would like to unit test that part as well.
Am I missing something and what would be the intended way to unit test the code that uses the actors?
Also, if it's not possible to mock the necessary components in order to write a unit test, how would you suggest to setup the infrastructure so that I can do integration tests with dapr runtime and the actors while also being able to debug my tests?
Any help is appreciated!
Contributor guide
Assessment
This issue has not been assessed yet.