// Test the InvalidOleVariantTypeException class. public void TestInvalidOleVariantTypeException() { // Check the three main exception constructors. ExceptionTester.CheckMain (typeof(InvalidOleVariantTypeException), unchecked ((int)0x80131531)); }
// Test the InvalidComObjectException class. public void TestInvalidComObjectException() { // Check the three main exception constructors. ExceptionTester.CheckMain (typeof(InvalidComObjectException), unchecked ((int)0x80131527)); }
// Test the SafeArrayTypeMismatchException class. public void TestSafeArrayTypeMismatchException() { // Check the three main exception constructors. ExceptionTester.CheckMain (typeof(SafeArrayTypeMismatchException), unchecked ((int)0x80131533)); }
// Test the MarshalDirectiveException class. public void TestMarshalDirectiveException() { // Check the three main exception constructors. ExceptionTester.CheckMain (typeof(MarshalDirectiveException), unchecked ((int)0x80131535)); }
// 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); }
// 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); }
// 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); }
// 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 }
// 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 }
// Test the RankException class. public void TestRankException() { ExceptionTester.CheckMain(typeof(RankException), unchecked ((int)0x80131517)); }
// Test the StackOverflowException class. public void TestStackOverflowException() { ExceptionTester.CheckMain(typeof(StackOverflowException), unchecked ((int)0x800703e9)); }
// Test the OverflowException class. public void TestOverflowException() { ExceptionTester.CheckMain(typeof(OverflowException), unchecked ((int)0x80131516)); }
// Test the PlatformNotSupportedException class. public void TestPlatformNotSupportedException() { ExceptionTester.CheckMain(typeof(PlatformNotSupportedException), unchecked ((int)0x80131539)); }
// Test the FieldAccessException class. public void TestFieldAccessException() { ExceptionTester.CheckMain(typeof(FieldAccessException), unchecked ((int)0x80131507)); }
// Test the OutOfMemoryException class. public void TestOutOfMemoryException() { ExceptionTester.CheckMain(typeof(OutOfMemoryException), unchecked ((int)0x8007000e)); }
// Test the TypeLoadException class. public void TestTypeLoadException() { ExceptionTester.CheckMain(typeof(TypeLoadException), unchecked ((int)0x80131522)); }
// Test the UnauthorizedAccessException class. public void TestUnauthorizedAccessException() { ExceptionTester.CheckMain(typeof(UnauthorizedAccessException), unchecked ((int)0x80070005)); }
// Test the FormatException class. public void TestFormatException() { ExceptionTester.CheckMain(typeof(FormatException), unchecked ((int)0x80131537)); }
// Test the SystemException class. public void TestSystemException() { ExceptionTester.CheckMain(typeof(SystemException), unchecked ((int)0x80131501)); }
// Test the MethodAccessException class. public void TestMethodAccessException() { ExceptionTester.CheckMain(typeof(MethodAccessException), unchecked ((int)0x80131510)); }
// Test the InvalidProgramException class. public void TestInvalidProgramException() { ExceptionTester.CheckMain(typeof(InvalidProgramException), unchecked ((int)0x8013153a)); }
// Test the InvalidOperationException class. public void TestInvalidOperationException() { ExceptionTester.CheckMain(typeof(InvalidOperationException), unchecked ((int)0x80131509)); }
// Test the InvalidCastException class. public void TestInvalidCastException() { ExceptionTester.CheckMain(typeof(InvalidCastException), unchecked ((int)0x80004002)); }
// Test the IndexOutOfRangeException class. public void TestIndexOutOfRangeException() { ExceptionTester.CheckMain(typeof(IndexOutOfRangeException), unchecked ((int)0x80131508)); }
// Test the ApplicationException class. public void TestApplicationException() { ExceptionTester.CheckMain(typeof(ApplicationException), unchecked ((int)0x80131600)); }
// Test the NotSupportedException class. public void TestNotSupportedException() { ExceptionTester.CheckMain(typeof(NotSupportedException), unchecked ((int)0x80131515)); }
// Test the TypeUnloadedException class. public void TestTypeUnloadedException() { ExceptionTester.CheckMain(typeof(TypeUnloadedException), unchecked ((int)0x80131013)); }
// Test the NullReferenceException class. public void TestNullReferenceException() { ExceptionTester.CheckMain(typeof(NullReferenceException), unchecked ((int)0x80004003)); }
// Test the NotImplementedException class. public void TestNotImplementedException() { ExceptionTester.CheckMain(typeof(NotImplementedException), unchecked ((int)0x80004001)); }
// Test the AppDomainUnloadedException class. public void TestAppDomainUnloadedException() { ExceptionTester.CheckMain(typeof(AppDomainUnloadedException), unchecked ((int)0x80131014)); }