title: How to mock ExceptionContext for testing using .NET Core 3 Web API and Moq
body: <p>In order to properly test a custom ExceptionFilterAttribute in .NET Core 3 we need to mock an ExceptionContext in an Xunit test using Moq. How can I do this?</p>
  
  <p>Exception Filter:</p>
  
  <pre><code>public class CustomExceptionFilter : ExceptionFilterAttribute
  {
    public override OnException(ExceptionContext context)
    {
      /* Code here that handles exceptions */
    }
  }
  </code></pre>
  
  <p>I've looked everywhere and can't figure out a good way to mock these things in a way that ensures nothing throws an exception due to other missing dependencies. How can I mock <code>ExceptionContext</code> easily?</p>