Software Design Blog

Journey of Rinat Abdullin

How to Count Methods With NotImplementedException?

Unit test like this will fail if more than 10 methods create NotImplementedException. On failing it will report all methods that create this exception.

var throwingMethods = codebase.Methods
  .Where(m => m
         .Exists(i => i.Creates<NotImplementedException>()))

if (throwingMethods.Length > 10)

Where codebase is created like this:

var codebase = new Codebase("Assembly1.dll","Assembly2.dll");

Snippet uses Lokad.Quality.dll from the Lokad Shared Libraries.