© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
12 replies
skmkqw

Is my unit testing approach correct?

Hello everybody, i'm getting into backend development in asp.net core and ef. i've already built a simple API, but it has an overkill architecure (made this in educational purposes). Now I'm trying to cover the whole project in unit tests. Since I use dbContext -> repository -> service -> controller pattern, i came up with an idea on how to test it: while testing the controller, i will create a mock service, while testing the service, i will create a mock repository, while testing the repository, I will create a fixture database with an example dataset. Does this make sense? You can see my latest code here https://github.com/skmkqw/ProjectManagementAPI at "unitTests" branch. I also hear of something called FluentAssertions. Should i user it from the beggining or should i introduce it later when I will get used to writing tests in regular xUnit?
GitHub
GitHub - skmkqw/ProjectManagementAPI
Contribute to skmkqw/ProjectManagementAPI development by creating an account on GitHub.
GitHub - skmkqw/ProjectManagementAPI
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

Similar Threads

What's correct unit testing?
C#CC# / help
3y ago
unit testing
C#CC# / help
2y ago
Unit testing
C#CC# / help
2y ago
✅ Unit testing
C#CC# / help
3y ago