Check that the method Namespace.Foo.Method(Int32) is 100% covered by tests

Rule ND9914 Samples of Custom rules / Check Coverage on particular Code Elements

A sample rule checking that a particular method is 100% covered by tests; adapt @"Namespace.Foo.Method(Int32)" and the threshold 100. Requires coverage data imported: https://www.ndepend.com/docs/code-coverage

How to fix

This is a sample rule, there is nothing to fix as is.

CQLinq source

This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Check that the method Namespace.Foo.Method(Int32) is 100% covered by tests</Name>
// <Id>ND9914:ExplicitId9914</Id>

warnif count > 0 from t in Application.Types where 
  (t.FullName == @"Namespace.Foo.Method(Int32)") && 
   t.PercentageCoverage < 100
select new { 
   t, 
   t.PercentageCoverage,
   Debt = t.NbLinesOfCodeNotCovered.ToMinutes().ToDebt(),
   Severity = Severity.High
}

//<Expl>
// The *{0}* is only *{1}* covered by tests while it should be 100% covered.
//</Expl>

//<Desc>
// A sample rule checking that a particular method is 100% covered by tests;
// adapt **@"Namespace.Foo.Method(Int32)"** and the threshold **100**.
// Requires coverage data imported: https://www.ndepend.com/docs/code-coverage
//</Desc>

//<HowToFix>
// This is a *sample rule*, there is nothing to fix *as is*.
//</HowToFix>

Samples of Custom rules / Check Coverage on particular Code Elements: all 4 items