c# Xunit, Assert.Throws fails when expected exception raised
<p><strong>EDIT:</strong> There is a similar question <a href="https://stackoverflow.com/questions/8635096/visual-studio-with-xunit-assert-throws-and-exception-was-unhandled-by-user-cod?rq=1">here</a>, but the solutions only suggest workarounds and provide no insights into the cause of the issue or how to fix it. This question may still be a duplicate.</p>

<p><strong>EDIT 2:</strong> It turns out this issue is <em>only</em> happening during debug, although it was not happening earlier. After replacing <code>(TCheck)null</code> with <code>null as TCheck</code> the tests pass when ran but throw an exception when debugged.</p>

<p><strong>ORIGINAL POST:</strong>
I have a method in a unit test that looks like this</p>

<pre><code>internal void EqualityAssert&lt;TCheck, TEquatable&gt;(TEquatable item, ... ) 
    where TCheck : class, IEquatable&lt;TEquatable&gt;, TEquatable
{

    // Various equality assertions that are passing
    // ...

    // A == null       
    Assert.Throws&lt;NullReferenceException&gt;(
    () =&gt; ((IEquatable&lt;TEquatable&gt;)item).Equals((TCheck)null));            
}
</code></pre>

<p>This method is called by various unit tests, and each of those tests are failing because an "Unhandled NullReferenceException was encountered" exactly where it is expected. </p>

<p>Assert.Throws was working properly for me earlier but I haven't been able to figure out what changed to break it.</p>