Exemplo n.º 1
0
    // Test the ArgumentNullException class.
    public void TestArgumentNullException()
    {
        ArgumentNullException e;

        e = new ArgumentNullException();
        AssertNull("ArgumentNullException (1)", e.ParamName);
        AssertNotNull("ArgumentNullException (2)", e.Message);
        ExceptionTester.CheckHResult
            ("ArgumentNullException (3)", e,
            unchecked ((int)0x80004003));

        e = new ArgumentNullException("p");
        AssertEquals("ArgumentNullException (4)", "p", e.ParamName);
        AssertNotNull("ArgumentNullException (5)", e.Message);
        ExceptionTester.CheckHResult
            ("ArgumentNullException (6)", e,
            unchecked ((int)0x80004003));

        e = new ArgumentNullException("p", "msg");
        AssertEquals("ArgumentNullException (7)", "p", e.ParamName);
        AssertEquals("ArgumentNullException (8)", "msg", e.Message);
        ExceptionTester.CheckHResult
            ("ArgumentNullException (9)", e,
            unchecked ((int)0x80004003));
    }
Exemplo n.º 2
0
    // Test the TypeInitializationException class.
    public void TestTypeInitializationException()
    {
        TypeInitializationException e;

        e = new TypeInitializationException(null, null);
        AssertEquals("TypeInitializationException (1)",
                     String.Empty, e.TypeName);
        AssertNotNull("TypeInitializationException (2)", e.Message);
        ExceptionTester.CheckHResult
            ("TypeInitializationException (3)", e,
            unchecked ((int)0x80131534));

        e = new TypeInitializationException("type", null);
        AssertEquals("TypeInitializationException (4)",
                     "type", e.TypeName);
        AssertNotNull("TypeInitializationException (5)", e.Message);
        ExceptionTester.CheckHResult
            ("TypeInitializationException (6)", e,
            unchecked ((int)0x80131534));

        e = new TypeInitializationException("type", e);
        AssertEquals("TypeInitializationException (7)",
                     "type", e.TypeName);
        AssertNotNull("TypeInitializationException (8)", e.Message);
        ExceptionTester.CheckHResult
            ("TypeInitializationException (9)", e,
            unchecked ((int)0x80131534));
    }
Exemplo n.º 3
0
    // Test the ObjectDisposedException class.
    public void TestObjectDisposedException()
    {
        ObjectDisposedException e;

        e = new ObjectDisposedException("obj");
        AssertEquals("ObjectDisposedException (1)",
                     "obj", e.ObjectName);
        AssertNotNull("ObjectDisposedException (2)", e.Message);
        ExceptionTester.CheckHResult
            ("ObjectDisposedException (3)", e,
            unchecked ((int)0x80131509));

        e = new ObjectDisposedException("obj", "msg");
        AssertEquals("ObjectDisposedException (4)",
                     "obj", e.ObjectName);
        AssertEquals("ObjectDisposedException (5)",
                     "obj: msg", e.Message);
        ExceptionTester.CheckHResult
            ("ObjectDisposedException (6)", e,
            unchecked ((int)0x80131509));

        e = new ObjectDisposedException(null, "msg");
        AssertNull("ObjectDisposedException (7)", e.ObjectName);
        AssertEquals("ObjectDisposedException (8)",
                     "msg", e.Message);
        ExceptionTester.CheckHResult
            ("ObjectDisposedException (9)", e,
            unchecked ((int)0x80131509));
    }
Exemplo n.º 4
0
    // Test the NotFiniteNumberException class.
    public void TestNotFiniteNumberException()
    {
        NotFiniteNumberException e;

        e = new NotFiniteNumberException();
        AssertEquals("NotFiniteNumberException (1)",
                     0.0, e.OffendingNumber);
        AssertNotNull("NotFiniteNumberException (2)", e.Message);
        ExceptionTester.CheckHResult
            ("NotFiniteNumberException (3)", e,
            unchecked ((int)0x80131528));

        e = new NotFiniteNumberException("msg");
        AssertEquals("NotFiniteNumberException (4)",
                     0.0, e.OffendingNumber);
        AssertEquals("NotFiniteNumberException (5)", "msg", e.Message);
        ExceptionTester.CheckHResult
            ("NotFiniteNumberException (6)", e,
            unchecked ((int)0x80131528));

        e = new NotFiniteNumberException("msg", 2.0);
        AssertEquals("NotFiniteNumberException (7)",
                     2.0, e.OffendingNumber);
        AssertEquals("NotFiniteNumberException (8)",
                     "msg", e.Message);
        ExceptionTester.CheckHResult
            ("NotFiniteNumberException (9)", e,
            unchecked ((int)0x80131528));
    }
Exemplo n.º 5
0
    // Test the DuplicateWaitObjectException class.
    public void TestDuplicateWaitObjectException()
    {
        DuplicateWaitObjectException e;

        e = new DuplicateWaitObjectException();
        AssertNull("DuplicateWaitObjectException (1)", e.ParamName);
        AssertNotNull("DuplicateWaitObjectException (2)", e.Message);
        ExceptionTester.CheckHResult
            ("DuplicateWaitObjectException (3)", e,
            unchecked ((int)0x80131529));

        e = new DuplicateWaitObjectException("p");
        AssertEquals("DuplicateWaitObjectException (4)",
                     "p", e.ParamName);
        AssertNotNull("DuplicateWaitObjectException (5)", e.Message);
        ExceptionTester.CheckHResult
            ("DuplicateWaitObjectException (6)", e,
            unchecked ((int)0x80131529));

        e = new DuplicateWaitObjectException("p", "msg");
        AssertEquals("DuplicateWaitObjectException (7)",
                     "p", e.ParamName);
        AssertEquals("DuplicateWaitObjectException (8)",
                     "msg", e.Message);
        ExceptionTester.CheckHResult
            ("DuplicateWaitObjectException (9)", e,
            unchecked ((int)0x80131529));
    }
Exemplo n.º 6
0
    // Test the ArgumentOutOfRangeException class.
    public void TestArgumentOutOfRangeException()
    {
        ArgumentOutOfRangeException e;

        e = new ArgumentOutOfRangeException();
        AssertNull("ArgumentOutOfRangeException (1)", e.ParamName);
        AssertNotNull("ArgumentOutOfRangeException (2)", e.Message);
        AssertNull("ArgumentOutOfRangeException (3)", e.ActualValue);
        ExceptionTester.CheckHResult
            ("ArgumentOutOfRangeException (4)", e,
            unchecked ((int)0x80131502));

        e = new ArgumentOutOfRangeException("p");
        AssertEquals("ArgumentOutOfRangeException (5)",
                     "p", e.ParamName);
        AssertNotNull("ArgumentOutOfRangeException (6)", e.Message);
        AssertNull("ArgumentOutOfRangeException (7)", e.ActualValue);
        ExceptionTester.CheckHResult
            ("ArgumentOutOfRangeException (8)", e,
            unchecked ((int)0x80131502));

        e = new ArgumentOutOfRangeException("p", "msg");
        AssertEquals("ArgumentOutOfRangeException (9)",
                     "p", e.ParamName);
        AssertEquals("ArgumentOutOfRangeException (10)",
                     "msg", e.Message);
        AssertNull("ArgumentOutOfRangeException (11)", e.ActualValue);
        ExceptionTester.CheckHResult
            ("ArgumentOutOfRangeException (12)", e,
            unchecked ((int)0x80131502));

        e = new ArgumentOutOfRangeException("p", 3, "msg");
        AssertEquals("ArgumentOutOfRangeException (13)",
                     "p", e.ParamName);
        Assert("ArgumentOutOfRangeException (14)",
               e.Message.StartsWith("msg"));
        AssertEquals("ArgumentOutOfRangeException (15)",
                     3, e.ActualValue);
        ExceptionTester.CheckHResult
            ("ArgumentOutOfRangeException (16)", e,
            unchecked ((int)0x80131502));
    }