EDIT: There is a similar question here, but the solutions only offer workarounds and do not give any information about the cause of the problem or how to fix it. This question may still be a duplicate.
EDIT 2: It turns out that this problem only occurs during debugging, although this has not happened before. After replacing (TCheck)nullwith null as TChecktests, they pass at startup, but they throw an exception during debugging.
ORIGINAL MAIL:
I have a method in unit test that looks like
internal void EqualityAssert<TCheck, TEquatable>(TEquatable item, ... )
where TCheck : class, IEquatable<TEquatable>, TEquatable
{
Assert.Throws<NullReferenceException>(
() => ((IEquatable<TEquatable>)item).Equals((TCheck)null));
}
, , " NullReferenceException " , .
Assert.Throws , , , .