Пример #1
0
        public virtual void TestXException()
        {
            XException ex = new XException(TestXException.TestERROR.Tc);

            NUnit.Framework.Assert.AreEqual(ex.GetError(), TestXException.TestERROR.Tc);
            NUnit.Framework.Assert.AreEqual(ex.Message, "TC: {0}");
            NUnit.Framework.Assert.IsNull(ex.InnerException);
            ex = new XException(TestXException.TestERROR.Tc, "msg");
            NUnit.Framework.Assert.AreEqual(ex.GetError(), TestXException.TestERROR.Tc);
            NUnit.Framework.Assert.AreEqual(ex.Message, "TC: msg");
            NUnit.Framework.Assert.IsNull(ex.InnerException);
            Exception cause = new Exception();

            ex = new XException(TestXException.TestERROR.Tc, cause);
            NUnit.Framework.Assert.AreEqual(ex.GetError(), TestXException.TestERROR.Tc);
            NUnit.Framework.Assert.AreEqual(ex.Message, "TC: " + cause.ToString());
            NUnit.Framework.Assert.AreEqual(ex.InnerException, cause);
            XException xcause = ex;

            ex = new XException(xcause);
            NUnit.Framework.Assert.AreEqual(ex.GetError(), TestXException.TestERROR.Tc);
            NUnit.Framework.Assert.AreEqual(ex.Message, xcause.Message);
            NUnit.Framework.Assert.AreEqual(ex.InnerException, xcause);
        }
Пример #2
0
 /// <summary>Creates an XException using another XException as cause.</summary>
 /// <remarks>
 /// Creates an XException using another XException as cause.
 /// <p>
 /// The error code and error message are extracted from the cause.
 /// </remarks>
 /// <param name="cause">exception cause.</param>
 public XException(XException cause)
     : this(cause.GetError(), cause.Message, cause)
 {
 }