Stand with the people of Ukraine: How to Help
A Diagnostic Analyzer and CodeFix Provider aimed to automate mocks creating and configuring.
You can use it as a Visual Studio Extension or install as a NuGet package.
For Visual Studio Code you should install a NuGet package and enable Roslyn Analyzers, see Example project.
Additionally, you can configure variable and field name templates.
In the Constructor or TestInitialize (SetUp for NUnit) marked method create the instance of your Service Under the Test (SUT).
After that you can see code analysis error and the following suggestions (lightbulbs):
Choose "Fill with mocks" - it will create the mocks required for your service and put them into constructor.
Create TestMethod (Test for NUnit) marked method and write here a call of any methods of your SUT.
If SUT's method uses any of injected instances Visual Studio shows you code analysis info.
Choose "Setup mocks with callbacks" or "Setup mocks" - it will setup the mock's methods and calls VerifyAll for each of them.
After that change all default(type) expressions to values you want.
This tool has been working well for my own personal needs, but outside that its future depends on your feedback. Feel free to open an issue.
Any donations during this time will be directed to local charities at my own discretion.
Privacy Notice: No personal data is collected at all.