Ejemplo n.º 1
0
        public void Constructor3_Message_Null()
        {
            ArithmeticException   ame = new ArithmeticException("something");
            FileNotFoundException fnf = new FileNotFoundException((string)null, ame);

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#1");
#endif
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNotNull(fnf.InnerException, "#3");
            Assert.AreSame(ame, fnf.InnerException, "#4");
#if NET_2_0
            Assert.IsNull(fnf.Message, "#5");
#else
            Assert.IsNotNull(fnf.Message, "#5"); // File or assembly name (null), or ...
#endif
            Assert.IsNull(fnf.FusionLog, "#6");
#if NET_2_0
#if TARGET_JVM
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ":  ---> "
                                                    + ame.GetType().FullName + ": something"), "#7");
#else
            Assert.AreEqual(fnf.GetType().FullName + ":  ---> "
                            + ame.GetType().FullName + ": something", fnf.ToString(), "#7");
#endif
#else
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName), "#7");
            Assert.IsFalse(fnf.ToString().IndexOf(Environment.NewLine) != -1, "#9");
#endif
        }
        public void Constructor3_Message_Null()
        {
            ArithmeticException     ame = new ArithmeticException("something");
            BadImageFormatException bif = new BadImageFormatException((string)null, ame);

#if NET_2_0
            Assert.IsNotNull(bif.Data, "#1");
#endif
            Assert.IsNull(bif.FileName, "#2");
            Assert.IsNotNull(bif.InnerException, "#3");
            Assert.AreSame(ame, bif.InnerException, "#4");
#if NET_2_0
            Assert.IsNotNull(bif.Message, "#5"); // Could not load file or assembly '' ...
            Assert.IsTrue(bif.Message.IndexOf("''") != -1, "#6");
#else
            Assert.IsNotNull(bif.Message, "#5"); // Format of the executable (.exe) or library ...
            Assert.IsFalse(bif.Message.IndexOf("''") != -1, "#6");
#endif
            Assert.IsNull(bif.FusionLog, "#7");
            Assert.IsTrue(bif.ToString().StartsWith(bif.GetType().FullName), "#8");
            Assert.IsTrue(bif.ToString().IndexOf("---> " + ame.GetType().FullName) != -1, "#9");
#if !TARGET_JVM // ToString always has a stack trace under TARGET_JVM
            Assert.IsFalse(bif.ToString().IndexOf(Environment.NewLine) != -1, "#10");
#endif // TARGET_JVM
        }
        public void Constructor3_Message_Empty()
        {
            ArithmeticException     ame = new ArithmeticException("something");
            BadImageFormatException bif = new BadImageFormatException(string.Empty, ame);

#if NET_2_0
            Assert.IsNotNull(bif.Data, "#1");
#endif
            Assert.IsNull(bif.FileName, "#2");
            Assert.IsNotNull(bif.InnerException, "#3");
            Assert.AreSame(ame, bif.InnerException, "#4");
            Assert.IsNotNull(bif.Message, "#5");
            Assert.AreEqual(string.Empty, bif.Message, "#6");
            Assert.IsNull(bif.FusionLog, "#7");
#if TARGET_JVM // ToString always has a stack trace under TARGET_JVM
            Assert.IsTrue(bif.ToString().IndexOf(ame.GetType().FullName + ": something") != -1, "#8");
#else
            Assert.AreEqual(bif.GetType().FullName + ":  ---> "
                            + ame.GetType().FullName + ": something", bif.ToString(), "#8");
#endif // TARGET_JVM
        }
Ejemplo n.º 4
0
        public void Constructor3_Message_Empty()
        {
            ArithmeticException   ame = new ArithmeticException("something");
            FileNotFoundException fnf = new FileNotFoundException(string.Empty, ame);

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#1");
#endif
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNotNull(fnf.InnerException, "#3");
            Assert.AreSame(ame, fnf.InnerException, "#4");
            Assert.IsNotNull(fnf.Message, "#5");
            Assert.AreEqual(string.Empty, fnf.Message, "#6");
            Assert.IsNull(fnf.FusionLog, "#7");
#if TARGET_JVM
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ":  ---> "
                                                    + ame.GetType().FullName + ": something"), "#8");
#else
            Assert.AreEqual(fnf.GetType().FullName + ":  ---> "
                            + ame.GetType().FullName + ": something", fnf.ToString(), "#8");
#endif
        }
        public void Constructor3_Message_Null()
        {
            ArithmeticException   ame = new ArithmeticException("something");
            FileNotFoundException fnf = new FileNotFoundException((string)null, ame);

            Assert.IsNotNull(fnf.Data, "#1");
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNotNull(fnf.InnerException, "#3");
            Assert.AreSame(ame, fnf.InnerException, "#4");
            Assert.IsNull(fnf.Message, "#5");
            Assert.IsNull(fnf.FusionLog, "#6");
            Assert.AreEqual(fnf.GetType().FullName + ":  ---> "
                            + ame.GetType().FullName + ": something", fnf.ToString(), "#7");
        }
        public void Constructor3_Message_Empty()
        {
            ArithmeticException     ame = new ArithmeticException("something");
            BadImageFormatException bif = new BadImageFormatException(string.Empty, ame);

            Assert.IsNotNull(bif.Data, "#1");
            Assert.IsNull(bif.FileName, "#2");
            Assert.IsNotNull(bif.InnerException, "#3");
            Assert.AreSame(ame, bif.InnerException, "#4");
            Assert.IsNotNull(bif.Message, "#5");
            Assert.AreEqual(string.Empty, bif.Message, "#6");
            Assert.IsNull(bif.FusionLog, "#7");
            Assert.AreEqual(bif.GetType().FullName + ":  ---> "
                            + ame.GetType().FullName + ": something", bif.ToString(), "#8");
        }
Ejemplo n.º 7
0
        public void Constructor3_Message_Null()
        {
            ArithmeticException     ame = new ArithmeticException("something");
            BadImageFormatException bif = new BadImageFormatException((string)null, ame);

            Assert.IsNotNull(bif.Data, "#1");
            Assert.IsNull(bif.FileName, "#2");
            Assert.IsNotNull(bif.InnerException, "#3");
            Assert.AreSame(ame, bif.InnerException, "#4");
            Assert.IsNotNull(bif.Message, "#5");
            Assert.IsNull(bif.FusionLog, "#7");
            Assert.IsTrue(bif.ToString().StartsWith(bif.GetType().FullName), "#8");
            Assert.IsTrue(bif.ToString().IndexOf("---> " + ame.GetType().FullName) != -1, "#9");
            Assert.IsFalse(bif.ToString().IndexOf(Environment.NewLine) != -1, "#10");
        }
Ejemplo n.º 8
0
        public void TryCatchFinallyWithExceptionInFinally()
        {
            // Uncaught Exception
            ArithmeticException exc = new ArithmeticException();

            // finally
            TestThrow <ArithmeticException> tt = new TestThrow <ArithmeticException>("Test Throw")
            {
                ExceptionExpression = (context => new ArithmeticException())
            };

            // Run test
            TestActivity act = CreateTryCatchFinally(null, null, tt, WFType.SEQ, false);

            TestRuntime.RunAndValidateAbortedException(act, exc.GetType(), null);
        }
Ejemplo n.º 9
0
        public void UncaughtExceptionFlowchart()
        {
            // exception which is raised
            ArithmeticException exc = new ArithmeticException();

            // try
            TestThrow <ArithmeticException> tt = new TestThrow <ArithmeticException>("Test Throw")
            {
                ExceptionExpression = (context => new ArithmeticException())
            };

            // catch
            TestCatch[] catches = new TestCatch[] { new TestCatch <FileNotFoundException>(),
                                                    new TestCatch <ArgumentException>(),
                                                    new TestCatch <ArgumentOutOfRangeException>() };

            // finally
            TestSequence finallySeq = new TestSequence("Finally");

            // create and run
            TestActivity act = CreateTryCatchFinally(tt, catches, finallySeq, WFType.FLOW, true);

            TestRuntime.RunAndValidateAbortedException(act, exc.GetType(), null);
        }