summaryrefslogtreecommitdiff
path: root/tests/src/Interop/MarshalAPI/GetExceptionForHR/GetExceptionForHR.cs
blob: 5280a0670f023a0770f856b8921051f461425d29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.IO;
using System.Reflection;
using System.Security;
using System.Runtime.InteropServices;
using System.Diagnostics;

public class GetExceptionForHRTest
{
    //HR:0x80020006
    void RunTests1()
    {
        
        int err = unchecked((int)0x80020006);
        Exception ex = Marshal.GetExceptionForHR(err);
        if(ex.HResult !=  err) throw new Exception();
    }

    //0x80020101
    void RunTest2()
    {     
        int err = unchecked((int)0x80020101);
        Exception ex = Marshal.GetExceptionForHR(err);             
        if(ex.HResult !=  err) throw new Exception();                
    }

    public bool RunTests()
    {
        RunTests1();
        RunTest2();
        return true;
    }

    public static int Main(String[] unusedArgs)
    {
        if (new GetExceptionForHRTest().RunTests())
            return 100;
        return 99;
    }

}