title: How to test or exclude private unreachable code from code coverage
body: <p>I have a bunch of assemblies with near 100% test coverage but I often run into a situation like in the example below. I cannot test the default switch case, which is there to guard against future bugs where I add more items to the enum but forget to update the switch statement to support new items.</p>
  
  <p>I would like to be able to either find a pattern where I can eliminate that "untestable" code, test it or mark <em>that line of code</em> (but not the entire method) to be excluded by the coverage analysis. </p>
  
  <p>It may sound silly but I do not want to assume the default case will never happen, and I do not want to bundle the default case with one that already exist. I want the exception to be thrown when I create such bugs. Which will happen sooner or later.</p>
  
  <p>I use <strong>DotCover</strong> to calculate coverage at the moment.</p>
  
  <p><strong>Note:</strong> This is <em>just example code</em> but I think it illustrates a fairly common pattern.</p>
  
  <pre><code>public class Tester
  {
      private enum StuffToDo
      {
          Swim = 0, 
          Bike,
          Run
      }
  
      public void DoSomeRandomStuff()
      {
          var random = new Random();
          DoStuff((StuffToDo)random.Next(3));
      }
  
      private void DoStuff(StuffToDo stuff)
      {
          switch (stuff)
          {
              case StuffToDo.Swim:
                  break;
              case StuffToDo.Bike:
                  break;
              case StuffToDo.Run:
                  break;
              default:
                  // How do I test or exclude this line from coverage?
                  throw new ArgumentOutOfRangeException("stuff");
          }
      }
  }
  </code></pre>