[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/attackgithub/pythonnet/mac-osx/src/testing/exceptiontest.cs [Back]  [Original]

using System;


namespace Python.Test
{
    //========================================================================
    // Supports CLR Exception unit tests.
    //========================================================================

    public class ExceptionTest
    {
        public int ThrowProperty
        {
            get { throw new OverflowException("error"); }
            set { throw new OverflowException("error"); }
        }

        public static Exception GetBaseException()
        {
            return new Exception("error");
        }

        public static OverflowException GetExplicitException()
        {
            return new OverflowException("error");
        }

        public static Exception GetWidenedException()
        {
            return new OverflowException("error");
        }

        public static ExtendedException GetExtendedException()
        {
            return new ExtendedException("error");
        }


        public static bool SetBaseException(Exception e)
        {
            return typeof(Exception).IsInstanceOfType(e);
        }

        public static bool SetExplicitException(OverflowException e)
        {
            return typeof(OverflowException).IsInstanceOfType(e);
        }

        public static bool SetWidenedException(Exception e)
        {
            return typeof(Exception).IsInstanceOfType(e);
        }

        public static bool ThrowException()
        {
            throw new OverflowException("error");
        }
    }


    public class ExtendedException : OverflowException
    {
        public ExtendedException() : base()
        {
        }

        public ExtendedException(string m) : base(m)
        {
        }

        public string extra = "extra";

        public string ExtraProperty
        {
            get { return extra; }
            set { extra = value; }
        }

        public string GetExtraInfo()
        {
            return extra;
        }
    }
}

Web Proxy Viewer  |  New URL  |  Original Page