ExceptionExtensionsTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Tests.Extensions ExceptionExtensionsTests

Namespace: DeltaEngine.Tests.Extensions
Assembly: DeltaEngine.Tests (in DeltaEngine.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class ExceptionExtensionsTests

The ExceptionExtensionsTests type exposes the following members.

Constructors

  NameDescription
Public methodExceptionExtensionsTests
Initializes a new instance of the ExceptionExtensionsTests class
Top
Methods

  NameDescription
Public methodCheckForFatalException
Public methodCheckForWeakException
Public methodIsDebugMode
Public methodMakeSureFatalExceptionsAreRethrown
Public methodRethrowWeakExceptionIfNoDebuggerIsAttached
Top
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