Example #1
0
 // Test the InvalidOleVariantTypeException class.
 public void TestInvalidOleVariantTypeException()
 {
     // Check the three main exception constructors.
     ExceptionTester.CheckMain
         (typeof(InvalidOleVariantTypeException),
         unchecked ((int)0x80131531));
 }
Example #2
0
 // Test the InvalidComObjectException class.
 public void TestInvalidComObjectException()
 {
     // Check the three main exception constructors.
     ExceptionTester.CheckMain
         (typeof(InvalidComObjectException),
         unchecked ((int)0x80131527));
 }
Example #3
0
 // Test the SafeArrayTypeMismatchException class.
 public void TestSafeArrayTypeMismatchException()
 {
     // Check the three main exception constructors.
     ExceptionTester.CheckMain
         (typeof(SafeArrayTypeMismatchException),
         unchecked ((int)0x80131533));
 }
Example #4
0
 // Test the MarshalDirectiveException class.
 public void TestMarshalDirectiveException()
 {
     // Check the three main exception constructors.
     ExceptionTester.CheckMain
         (typeof(MarshalDirectiveException),
         unchecked ((int)0x80131535));
 }
Example #5
0
    // Test the BadImageFormatException class.
    public void TestBadImageFormatException()
    {
        BadImageFormatException e;

        ExceptionTester.CheckMain(typeof(BadImageFormatException),
                                  unchecked ((int)0x8007000b));
        e = new BadImageFormatException();
        AssertNull("BadImageFormatException (1)", e.FileName);
        e = new BadImageFormatException("msg");
        AssertNull("BadImageFormatException (2)", e.FileName);
        e = new BadImageFormatException("msg", "file");
        AssertEquals("BadImageFormatException (3)", "file", e.FileName);
        e = new BadImageFormatException("msg", "file", e);
        AssertEquals("BadImageFormatException (4)", "file", e.FileName);
    }
Example #6
0
    // Test the ArgumentException class.
    public void TestArgumentException()
    {
        ArgumentException e;

        ExceptionTester.CheckMain(typeof(ArgumentException),
                                  unchecked ((int)0x80070057));
        e = new ArgumentException();
        AssertNull("ArgumentException (1)", e.ParamName);
        e = new ArgumentException("msg");
        AssertNull("ArgumentException (2)", e.ParamName);
        e = new ArgumentException("msg", "p");
        AssertEquals("ArgumentException (3)", "p", e.ParamName);
        e = new ArgumentException("msg", "p", e);
        AssertEquals("ArgumentException (4)", "p", e.ParamName);
    }
Example #7
0
    // Test the COMException class.
    public void TestCOMException()
    {
        // Check the three main exception constructors.
        ExceptionTester.CheckMain
            (typeof(COMException), unchecked ((int)0x80004005));

        // Test the fourth constructor.
        COMException e = new COMException("foobar", 0x0BADBEEF);

        AssertEquals("COM (1)", "foobar", e.Message);
        AssertEquals("COM (2)", 0x0BADBEEF, e.ErrorCode);

        // Test that the error code is zero by default.
        e = new COMException("foobar");
        AssertEquals("COM (3)", "foobar", e.Message);
        AssertEquals("COM (4)", 0, e.ErrorCode);
    }
Example #8
0
 // Test the MissingMethodException class.
 public void TestMissingMethodException()
 {
     ExceptionTester.CheckMain(typeof(MissingMethodException),
                               unchecked ((int)0x80131513));
                     #if !ECMA_COMPAT && CONFIG_SERIALIZATION
     MissingMethodException e;
     e = new MissingMethodException("x", "y");
     SerializationInfo info =
         new SerializationInfo(typeof(MissingMethodException),
                               new FormatterConverter());
     StreamingContext context = new StreamingContext();
     e.GetObjectData(info, context);
     AssertEquals("MissingMethodException (1)",
                  "x", info.GetString("MMClassName"));
     AssertEquals("MissingMethodException (2)",
                  "y", info.GetString("MMMemberName"));
                     #endif
 }
Example #9
0
    // Test the Exception class.
    public void TestException()
    {
        ExceptionTester.CheckMain(typeof(Exception),
                                  unchecked ((int)0x80131500));
                        #if !ECMA_COMPAT
        // Test the properties of a non-thrown exception.
        Exception e = new Exception();
        AssertNull("TestException (1)", e.HelpLink);
        e.HelpLink = "foo";
        AssertEquals("TestException (2)", "foo", e.HelpLink);
        e.HelpLink = "bar";
        AssertEquals("TestException (3)", "bar", e.HelpLink);
        AssertNull("TestException (4)", e.Source);
        AssertNull("TestException (5)", e.TargetSite);
        AssertEquals("TestException (6)",
                     String.Empty, e.StackTrace);
        e.Source = "src";
        AssertEquals("TestException (7)", "src", e.Source);

        // Test the properties of a thrown exception.
        Exception e2 = null;
        try
        {
            throw new Exception();
        }
        catch (Exception e3)
        {
            e2 = e3;
        }
        AssertNotNull("TestException (8)", e2);
        AssertNotNull("TestException (9)", e2.Source);
        Assert("TestException (10)",
               e2.Source.StartsWith("Testruntime, Version="));
        AssertNotNull("TestException (11)", e2.TargetSite);
        AssertEquals("TestException (12)",
                     "Void TestException()", e2.TargetSite.ToString());
        Assert("TestException (13)",
               e2.StackTrace != String.Empty);
                        #endif
    }
Example #10
0
 // Test the RankException class.
 public void TestRankException()
 {
     ExceptionTester.CheckMain(typeof(RankException),
                               unchecked ((int)0x80131517));
 }
Example #11
0
 // Test the StackOverflowException class.
 public void TestStackOverflowException()
 {
     ExceptionTester.CheckMain(typeof(StackOverflowException),
                               unchecked ((int)0x800703e9));
 }
Example #12
0
 // Test the OverflowException class.
 public void TestOverflowException()
 {
     ExceptionTester.CheckMain(typeof(OverflowException),
                               unchecked ((int)0x80131516));
 }
Example #13
0
 // Test the PlatformNotSupportedException class.
 public void TestPlatformNotSupportedException()
 {
     ExceptionTester.CheckMain(typeof(PlatformNotSupportedException),
                               unchecked ((int)0x80131539));
 }
Example #14
0
 // Test the FieldAccessException class.
 public void TestFieldAccessException()
 {
     ExceptionTester.CheckMain(typeof(FieldAccessException),
                               unchecked ((int)0x80131507));
 }
Example #15
0
 // Test the OutOfMemoryException class.
 public void TestOutOfMemoryException()
 {
     ExceptionTester.CheckMain(typeof(OutOfMemoryException),
                               unchecked ((int)0x8007000e));
 }
Example #16
0
 // Test the TypeLoadException class.
 public void TestTypeLoadException()
 {
     ExceptionTester.CheckMain(typeof(TypeLoadException),
                               unchecked ((int)0x80131522));
 }
Example #17
0
 // Test the UnauthorizedAccessException class.
 public void TestUnauthorizedAccessException()
 {
     ExceptionTester.CheckMain(typeof(UnauthorizedAccessException),
                               unchecked ((int)0x80070005));
 }
Example #18
0
 // Test the FormatException class.
 public void TestFormatException()
 {
     ExceptionTester.CheckMain(typeof(FormatException),
                               unchecked ((int)0x80131537));
 }
Example #19
0
 // Test the SystemException class.
 public void TestSystemException()
 {
     ExceptionTester.CheckMain(typeof(SystemException),
                               unchecked ((int)0x80131501));
 }
Example #20
0
 // Test the MethodAccessException class.
 public void TestMethodAccessException()
 {
     ExceptionTester.CheckMain(typeof(MethodAccessException),
                               unchecked ((int)0x80131510));
 }
Example #21
0
 // Test the InvalidProgramException class.
 public void TestInvalidProgramException()
 {
     ExceptionTester.CheckMain(typeof(InvalidProgramException),
                               unchecked ((int)0x8013153a));
 }
Example #22
0
 // Test the InvalidOperationException class.
 public void TestInvalidOperationException()
 {
     ExceptionTester.CheckMain(typeof(InvalidOperationException),
                               unchecked ((int)0x80131509));
 }
Example #23
0
 // Test the InvalidCastException class.
 public void TestInvalidCastException()
 {
     ExceptionTester.CheckMain(typeof(InvalidCastException),
                               unchecked ((int)0x80004002));
 }
Example #24
0
 // Test the IndexOutOfRangeException class.
 public void TestIndexOutOfRangeException()
 {
     ExceptionTester.CheckMain(typeof(IndexOutOfRangeException),
                               unchecked ((int)0x80131508));
 }
Example #25
0
 // Test the ApplicationException class.
 public void TestApplicationException()
 {
     ExceptionTester.CheckMain(typeof(ApplicationException),
                               unchecked ((int)0x80131600));
 }
Example #26
0
 // Test the NotSupportedException class.
 public void TestNotSupportedException()
 {
     ExceptionTester.CheckMain(typeof(NotSupportedException),
                               unchecked ((int)0x80131515));
 }
Example #27
0
 // Test the TypeUnloadedException class.
 public void TestTypeUnloadedException()
 {
     ExceptionTester.CheckMain(typeof(TypeUnloadedException),
                               unchecked ((int)0x80131013));
 }
Example #28
0
 // Test the NullReferenceException class.
 public void TestNullReferenceException()
 {
     ExceptionTester.CheckMain(typeof(NullReferenceException),
                               unchecked ((int)0x80004003));
 }
Example #29
0
 // Test the NotImplementedException class.
 public void TestNotImplementedException()
 {
     ExceptionTester.CheckMain(typeof(NotImplementedException),
                               unchecked ((int)0x80004001));
 }
Example #30
0
 // Test the AppDomainUnloadedException class.
 public void TestAppDomainUnloadedException()
 {
     ExceptionTester.CheckMain(typeof(AppDomainUnloadedException),
                               unchecked ((int)0x80131014));
 }