Beispiel #1
0
        public void FatalityTest()
        {
            var nonfatal1 = new ApplicationException("exception1");
            var nonfatal2 = new InsufficientMemoryException("Oops");
            var fatal1    = new OutOfMemoryException("Oops");
            var fatal2    = new DataException();
            var fatal3    = new AccessViolationException("Oops");
            var fatal4    = new SEHException("Oops");
            var fatal5    = new TypeInitializationException("fulltypename", fatal1);
            var fatal6    = new TargetInvocationException(fatal1);
            var fatal7    = new AggregateException("Oops", new Exception[] { fatal1, fatal2 });
            var fatal8    = new AggregateException("Oops", fatal7);

            Assert.IsFalse(((Exception)null).IsFatal(), "Null should be non fatal");
            Assert.IsFalse(nonfatal1.IsFatal(), "Non fatal 1 expected");
            Assert.IsFalse(nonfatal2.IsFatal(), "Non fatal 2 expected");
            Assert.IsTrue(fatal1.IsFatal(), "Fatal 1 expected");
            Assert.IsTrue(fatal2.IsFatal(), "Fatal 2 expected");
            Assert.IsTrue(fatal3.IsFatal(), "Fatal 3 expected");
            Assert.IsTrue(fatal4.IsFatal(), "Fatal 4 expected");
            Assert.IsTrue(fatal5.IsFatal(), "Fatal 5 expected");
            Assert.IsTrue(fatal6.IsFatal(), "Fatal 6 expected");
            Assert.IsTrue(fatal7.IsFatal(), "Fatal 7 expected");
            Assert.IsTrue(fatal8.IsFatal(), "Fatal 8 expected");
        }