The switch statement in following code has a default
clause that is required by the compiler and a nice safeguard, but which is never executed. After writing tests for everything else, there is no way I can (or should) test that one line. I don't care that I haven't covered that line with tests, but my TestDriven.net NCover code coverage report does show the untested line and this causes the class coverage to drop to 86%. Is there a way to let NCover exclude just this one line?
public static class OperandTypeExtensions
{
public static string ToShortName(this OperandType type)
{
#region Contract
Contract.Requires<InvalidEnumArgumentException>(Enum.IsDefined(typeof(OperandType), type));
#endregion
switch (type)
{
case OperandType.None: return "<none>";
case OperandType.Int32: return "i32";
case OperandType.Int64: return "i64";
default:
throw new NotSupportedException();
}
}
}
My question is similar to this question, but none of the answers help in my specific situation.