© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
65 replies
Pibbles

Unit Testing Classes with Dependency Injection (ASP.NET Core)

How do you guys usually handle this? I saw some people mock every single injection which seems pretty horrible, other people end up in a way where they effectively have to rebuild the Program.cs class in their test project.

I'm using xUnit

To be a little more clear. The class I want to test on takes in some interfaces via dependency injection in it's constructor, and these are used in the methods I want to test. - Ideally, I want them to function how they actually would, using the concerete classes injected
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

❔ ASP.NET Core Environment Variables in Dependency Injection
C#CC# / help
3y ago
Dependency Injection in ASP.NET Core and issue with null suppresion
C#CC# / help
4y ago
Unit Testing ASP.NET async api service
C#CC# / help
17mo ago
dependency-injection-dotnet-core
C#CC# / help
2y ago