public void TestSuppressFailFast() { Assert.False(ExceptionHelpers.IsFailFastSuppressed()); using (ExceptionHelpers.SuppressFailFast()) { Assert.True(ExceptionHelpers.IsFailFastSuppressed()); } Assert.False(ExceptionHelpers.IsFailFastSuppressed()); }
public void TestExecuteWithErrorReportingWithSuppressFailFast() { bool finallyExecuted = false; void a() { try { throw new ArgumentOutOfRangeException(); } finally { finallyExecuted = true; } } try { using (ExceptionHelpers.SuppressFailFast()) { try { a(); } catch (Exception e) when(FatalError.ReportUnlessCanceled(e)) { throw ExceptionUtilities.Unreachable; } Assert.True(false, "Should not get here because an exception should be thrown before this point."); } } catch (ArgumentOutOfRangeException) { Assert.True(finallyExecuted); } Assert.False(ExceptionHelpers.IsFailFastSuppressed()); }