Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

ycherkes/MockIt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I recommend using Unitverse C# Unit Test Generator Visual Studio extension as it supports Mock and NSubstitute and generates full test classes.

MockIt

marketplace marketplace installs nuget downloads

License: Apache 2.0

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.

Quick introduction:

Create the instance of your Service Under the Test (SUT) in the Constructor or TestInitialize (SetUp for NUnit) marked method.

After that you can see code analysis error and the following suggestions (lightbulbs):

  • to create a constructor without parameters
  • to fill with mocks

Choose "Fill with mocks" - it will create the mocks required for your service and put them into constructor.

Create TestMethod (Test for NUnit, Fact or Theory for xUnit) 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.

alt tag

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.

PayPal

Any donations during this time will be directed to local charities at my own discretion.

Privacy Notice: No personal data is collected at all.

About

MockIt is a Diagnostic Analyzer and CodeFix Provider for generating mocks for the Moq framework.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published