Skip to content
| Marketplace
Sign in
Visual Studio>Tools>MockIt.Vsix

MockIt.Vsix

Yevhen Cherkes

|
2,971 installs
| (0) | Free
A Visual Studio extension to automate mocks creating and configuring

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):

  • to create a constructor without parameters
  • to make mock

 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

  • v 1.0.0.10 Fixed mocks detection when mocked classes/interfaces are declared in different assembly than sut
  • v 1.0.0.17 Partial support the chains of mocks
  • v 1.0.0.19 Using statement support
  • v 1.0.0.21 Bugs fixing
  • v 1.0.0.22 xUnit.Net added to supportable test frameworks
  • v 1.0.0.23 Visual Studio 2017 compatibility, bugs fixing

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:

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2022 Microsoft