title: UnitTest ApiController with ExceptionFilterAttribute
body: <p>i'm trying to UnitTest my controller where an exception is catch by the ExceptionFilterAttribute and launched back as a HttpResponseException. </p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>[ExceptionFilters] //ExceptionFilterAttribute
  public class EleveController : ApiController
  { 
    private IGpiRepository _gpiRepository;
  
    public EleveController(IGpiRepository gpiRepository)
    {
       _gpiRepository = gpiRepository;
    }
  
    [HttpGet]
    [Route("{fiche:int}/grouperepere")]
    public GroupeRepere GroupeRepere(int fiche) //This What Im trying to test
    {
       GpiService service = new GpiService(_gpiRepository);
       return service.Get(fiche); //Throw an ArgumentNullException when fiche == 0
    }
  }
  </code></pre>
  
  <p><strong>ExceptionFilter</strong></p>
  
  <pre><code>public class ExceptionFilters : ExceptionFilterAttribute
  {
    public override void OnException(HttpActionExecutedContext context)
    {
       if (context.Exception is NotImplementedException)
       {
          context.Response = new HttpResponseMessage(HttpStatusCode.NotImplemented);
       }
       else if (context.Exception is ArgumentNullException)
       {
          context.Response = new HttpResponseMessage(HttpStatusCode.BadRequest)
          {
             Content = new StringContent(string.Format("Argument \"{0}\" is null or invalid", ((ArgumentNullException)context.Exception).ParamName)),
             ReasonPhrase = "Argument null or invalid"
          };
       }
    }
  </code></pre>
  
  <p>and this is my test:</p>
  
  <pre><code>  private IGpiRepository _gpiRepository;
    private Mock&lt;ICallApi&gt; _callApi;
    private EleveController _controller;
  
    [TestInitialize]
    public void Initialize()
    {
       _callApi = new Mock&lt;ICallApi&gt;();
       _gpiRepository = new GpiRepository(_callApi.Object);
       _controller = new EleveController(_gpiRepository);
    }
  
    [TestMethod]
    public void EleveController__GroupeRepere_WithBadFiche_400BadRequest()
    {
       string noGroupe = "111";
       int fiche = 0;
       try
       {
          GroupeRepere gp = _controller.GroupeRepere(fiche);
  
          Assert.Fail();
       }
       catch (Exception e)
       {
          Assert.IsTrue(e is HttpResponseException); // not working --&gt; ArgumentNullException
       }
    }
  </code></pre>
  
  <p>The problem is that <code>e</code> still is an <code>ArgumentNullException</code>. When i go on debug, it doesn't even reach the <code>ExceptionFilter class</code></p>
  
  <p>Am i missing something?
  Thanks.</p>