Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.14 KB

File metadata and controls

39 lines (29 loc) · 1.14 KB

NS2004

CheckId NS2004
Category Substitute creation

Cause

Substituting for type by passing wrong constructor arguments.

Rule description

A violation of this rule occurs when Substitute.ForPartsOf or Substitute.For is used with arguments which do not match constructor arguments of substituted type.

How to fix violations

To fix a violation of this rule, use Substitute.ForPartsOf or Substitute.For and pass arguments which match constructor arguments of substituted type.

How to suppress violations

This warning can be suppressed by disabling the warning in the ruleset file for the project. The warning can also be suppressed programmatically for an assembly:

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Substitute creation", "NS2004:Unable to find matching constructor.", Justification = "Reviewed")]

Or for a specific code block:

#pragma warning disable NS2004 // Unable to find matching constructor.
// the code which produces warning
#pragma warning restore NS2004 // Unable to find matching constructor.