Savage
✅ Problems with mocking a ServiceProvider
Hmm. I still ran into a problem: the
ActorProvider
constructor takes an IServiceProvider
instance as an argument.
Thus, to create a substitute for it, I first need to have serviceProvider
initialized.
Thanks for the insightful response however and the tips! I realize my problem might be too specific/ niche without (especially without full context).
Have a great day! 😄70 replies
✅ Problems with mocking a ServiceProvider
If I am not missing something (and I looked for it multiple times in the past few days), in the actual program the service provider is initialized when the builder is created. That is what confused me when it came to creating the service provider myself :d
70 replies
✅ Problems with mocking a ServiceProvider
Hmm I read it and what I want to test isn't as broad as integration tests are described there.
I can't describe it simply as a unit test either as two classes/ subsystems are involved.
However, for the test(s) in question, no database or web server are needed.
70 replies
✅ Problems with mocking a ServiceProvider
I am not sure I understand your initial question, but let me present why I need
CreateScope()
.
The project uses the actor model. The actor provider (basically a factory) has these:
Thus, I need some way to mock the scope and context for those functions to work.
Indeed, in the actual program (not the test), those work right after the WebApplicationBuilder is created (var builder = WebApplication.CreateBuilder(args);
)
Are you saying that I should go one level deeper in my test and create a substitute/ mock for the builder?70 replies