CheckId | NS2004 |
Category | Substitute creation |
Substituting for type by passing wrong constructor arguments.
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.
To fix a violation of this rule, use Substitute.ForPartsOf
or Substitute.For
and pass arguments which match constructor arguments of substituted type.
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.