A Visual Studio helper to create and configure mocks with Moq lib in the unit tests (MSTest, NUnit, xUnit.Net). How to use it: In the TestInitialize, SetUp or ctor create the instance of your Service under the test (sut). After that you can see code analysis error and the next suggestions (lightbulbs):
Choose "Make mock" - it will create the mocks required for your service and put them into constructor. Create TestMethod 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 your code analysis info. Choose "Make mock" - 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. Using a hotkeys: F8 (Go to nex error-warning-info) or F12 with Resharper -> Ctrl + . (Show potential fixes - Smart Tags menu) or Alt + Enter with Resharper -> m (select "Make mock" in the menu) -> Enter Release Notes
Plans Add support for factories via delegates and Func Strict injected vars tracking (currently only by type of var) Add support for Moq.AutoMocker Sample for the factories mocking and using statement: |