Just because you can see the details of an exception in the output does not necessarily mean that NUnit knows about the exception.
AppDomain.UnhandledException , (, , ):
bool exceptionWasThrown = false;
UnhandledExceptionEventHandler unhandledExceptionHandler = (s, e) =>
{
if (!exceptionWasThrown)
{
exceptionWasThrown = true;
}
};
AppDomain.CurrentDomain.UnhandledException += unhandledExceptionHandler;
AppDomain.CurrentDomain.UnhandledException -= unhandledExceptionHandler;
Assert.IsFalse(exceptionWasThrown, "There was at least one unhandled exception");
, :
UnhandledExceptionEventHandler unhandledExceptionHandler = (s, e) =>
{
if (!exceptionWasThrown)
{
exceptionWasThrown = e.ExceptionObject.GetType() ==
typeof(PassedSystem.ArgumentException);
}
};