Skip to content

rjmurillo/moq.analyzers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Moq.Analyzers

NuGet Version NuGet Downloads Main build Codacy Grade Badge Codacy Coverage Badge

Moq.Analyzers is a Roslyn analyzer that helps you to write unit tests using the popular Moq framework. Moq.Analyzers protects you from common mistakes and warns you if something is wrong with your Moq configuration.

Analyzer rules

ID Category Title
Moq1000 Usage Sealed classes cannot be mocked
Moq1001 Usage Mocked interfaces cannot have constructor parameters
Moq1002 Usage Parameters provided into mock do not match any existing constructors
Moq1100 Correctness Callback signature must match the signature of the mocked method
Moq1101 Usage SetupGet/SetupSet/SetupProperty should be used for properties, not for methods
Moq1200 Correctness Setup should be used only for overridable members
Moq1201 Correctness Setup of async methods should use .ReturnsAsync instance instead of .Result
Moq1202 Correctness Raise event arguments should match the event delegate signature
Moq1203 Correctness Method setup should specify a return value
Moq1204 Correctness Raises event arguments should match event signature
Moq1205 Correctness Event setup handler type should match event delegate type
Moq1210 Correctness Verify should be used only for overridable members
Moq1300 Usage Mock.As() should take interfaces only
Moq1301 Usage Mock.Get() should not take literals
Moq1400 Best Practice Explicitly choose a mocking behavior instead of relying on the default (Loose) behavior
Moq1410 Best Practice Explicitly set the Strict mocking behavior

See docs/rules/README.md for full documentation.

Getting started

Moq.Analyzers is installed from NuGet. Run this command for your test project(s):

dotnet add package Moq.Analyzers

NOTE: You must use a supported version of the .NET SDK (i.e. 8.0 or later).

Configuring rules

Moq.Analyzers follows existing conventions for enabling, disabling, or suppressing rules. See Suppress code analysis warnings - .NET | Microsoft Learn for documentation on how to configure rules for your project.

Contributions welcome

Moq.Analyzers continues to evolve and add new features. Any help will be appreciated. You can report issues, develop new features, improve the documentation, or do other cool stuff. See CONTRIBUTING.md.

About

Set of analyzers for Moq mocking library

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 9

Languages