I wrote a small library that can generate mocks automatically for a class under test. It takes away the unnecessary typing of lines and also improves consistency on how the test classes look like.
You can use it by installing AutoSetup nuget package from your unit test project.
Just create a new unit test class with name “SomethingTests”, on the quick actions menu click (Re-)Generate Setup. A class with name “Something” will be found from within the solution and for each of the constructor dependencies, a mock will be generated.
Example some class under test:
Generated mocks for this class:
Would like to spread the word by this post and similarly by this other article with the hope that it helps some people!
no comments yet
Be the first to share what you think!
C# devs
null reference exceptions