Testing multi layered .NET application
Hey, I'm new to C#/.NET and i'm currently making my first project.
This project has a Controller - Service - Repository structure.
Right now I'm trying to write tests for my controllers but I'm facing a problem trying to mock my service.
In the setup of my mock, i pass the data it should return, but the result is null (without the returned data)
Can anyone help me? I have added screenshots of the code.
1 Reply
@Denge First, I would suggest you create your generally Mocks with
MockBehavior.Strict
, this way they fail if the mocked behavior isn't setup.
Which probably leads to the actual issue: You probably didn't do the setup of your mocks.
I don't see what isn't done properly based on your code, but if it returns null, then there must be something wrong.