You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

Moq.Analyzers

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Moq.Analyzers

Roslyn analyzer that helps to write unit tests using Moq mocking library by highlighting typical errors and suggesting quick fixes. Port of Resharper extension to Roslyn. Find the full list of detected issues at project GitHub page.

0.3.0
Source
nugetNuGet
Version published
Maintainers
2
Created
Source

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

  • Moq1000: Sealed classes cannot be mocked
  • Moq1001: Mocked interfaces cannot have constructor parameters
  • Moq1002: Parameters provided into mock do not match any existing constructors
  • Moq1100: Callback signature must match the signature of the mocked method
  • Moq1101: SetupGet/SetupSet should be used for properties, not for methods
  • Moq1200: Setup should be used only for overridable members
  • Moq1201: Setup of async methods should use .ReturnsAsync instance instead of .Result
  • Moq1300: Mock.As() should take interfaces
  • Moq1400: Explicitly choose a mocking behavior instead of relying on the default (Loose) behavior
  • Moq1410: Explicitly set the Strict mocking behavior

See docs/rules 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. 6.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.

Keywords

moq

FAQs

Package last updated on 21 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts