Inheritance Hierarchy
DeltaEngine.Tests.Extensions ExceptionExtensionsTests
Namespace: DeltaEngine.Tests.Extensions
Assembly: DeltaEngine.Tests (in DeltaEngine.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The ExceptionExtensionsTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
ExceptionExtensionsTests | Initializes a new instance of the ExceptionExtensionsTests class |
Methods
Name | Description | |
---|---|---|
CheckForFatalException | ||
CheckForWeakException | ||
IsDebugMode | ||
MakeSureFatalExceptionsAreRethrown | ||
RethrowWeakExceptionIfNoDebuggerIsAttached |
Examples
[Test] public void CheckForFatalException() { Assert.IsFalse(new Exception().IsFatal()); Assert.IsTrue(new Exception("", new InvalidOperationException()).IsFatal()); Assert.IsTrue(new InvalidOperationException().IsFatal()); Assert.IsTrue(new OutOfMemoryException().IsFatal()); Assert.IsTrue(new AccessViolationException().IsFatal()); Assert.IsTrue(new StackOverflowException().IsFatal()); Assert.IsTrue(new TargetInvocationException(null).IsFatal()); Assert.IsFalse(new NullReferenceException(null).IsFatal()); }
[Test] public void CheckForWeakException() { Assert.IsFalse(new Exception().IsWeak()); Assert.IsTrue(new ArgumentNullException().IsWeak()); }
[Test] public void MakeSureFatalExceptionsAreRethrown() { try { TryMakeSureFatalExceptionsAreRethrown(); } // ncrunch: no coverage catch (Exception ex) { Assert.IsTrue(ex.IsFatal()); } }
[Test] public void RethrowWeakExceptionIfNoDebuggerIsAttached() { try { TryRethrowWeakExceptionIfNoDebuggerIsAttached(); } // ncrunch: no coverage catch (Exception ex) { // This will fail if debugger is attached, but that is expected Assert.IsTrue(ex.IsWeak()); } }
[Test] public void IsDebugMode() { #if DEBUG Assert.IsTrue(ExceptionExtensions.IsDebugMode); #else Assert.IsFalse(ExceptionExtensions.IsDebugMode); #endif }
See Also