示例#1
0
    public static void Out()
    {
        IntPtr handleValue = MyCriticalHandle.GetUniqueHandle();

        MyCriticalHandle[] myCriticalHandleArray;
        Assert.Throws <MarshalDirectiveException>(() => Native.Out(handleValue, out myCriticalHandleArray));
    }
示例#2
0
    public static void Out()
    {
        IntPtr handleValue = MyCriticalHandle.GetUniqueHandle();

        Native.MyCriticalHandleStruct handleStruct;
        Assert.Throws <NotSupportedException>(() => Native.Out(handleValue, out handleStruct));
    }
示例#3
0
    public static void In()
    {
        IntPtr handleValue = MyCriticalHandle.GetUniqueHandle();

        InWorker(handleValue);
        GC.Collect();
        GC.WaitForPendingFinalizers();
        Assert.IsTrue(MyCriticalHandle.IsHandleClosed(handleValue), "Handle was not closed");
    }
示例#4
0
文件: Test.cs 项目: z77ma/runtime
    public static void Ref()
    {
        IntPtr handleValue = MyCriticalHandle.GetUniqueHandle();

        RefWorker(handleValue);
        GC.Collect();
        GC.WaitForPendingFinalizers();
        Assert.True(MyCriticalHandle.IsHandleClosed(handleValue));
    }
示例#5
0
    public static void In()
    {
        IntPtr handleValue = MyCriticalHandle.GetUniqueHandle();

        MyCriticalHandle[] myCriticalHandleArray = new MyCriticalHandle[] { new MyCriticalHandle()
                                                                            {
                                                                                Handle = handleValue
                                                                            } };
        Assert.Throws <MarshalDirectiveException>(() => Native.In(myCriticalHandleArray));
    }
示例#6
0
    public static void RefModify()
    {
        IntPtr handleValue1 = MyCriticalHandle.GetUniqueHandle();
        IntPtr handleValue2 = MyCriticalHandle.GetUniqueHandle();

        MyCriticalHandle[] myCriticalHandleArray = new MyCriticalHandle[] { new MyCriticalHandle()
                                                                            {
                                                                                Handle = handleValue1
                                                                            } };
        Assert.Throws <MarshalDirectiveException>(() => Native.RefModify(handleValue2, ref myCriticalHandleArray));
    }
示例#7
0
    public static void RefModify()
    {
        IntPtr handleValue1 = MyCriticalHandle.GetUniqueHandle();
        IntPtr handleValue2 = MyCriticalHandle.GetUniqueHandle();

        RefModifyWorker(handleValue1, handleValue2);
        GC.Collect();
        GC.WaitForPendingFinalizers();
        Assert.IsTrue(MyCriticalHandle.IsHandleClosed(handleValue1), "Handle 1 was not closed");
        Assert.IsTrue(MyCriticalHandle.IsHandleClosed(handleValue2), "Handle 2 was not closed");
    }
示例#8
0
    public static void RefModify()
    {
        IntPtr handleValue1 = MyCriticalHandle.GetUniqueHandle();
        IntPtr handleValue2 = MyCriticalHandle.GetUniqueHandle();

        Native.MyCriticalHandleStruct handleStruct = new Native.MyCriticalHandleStruct()
        {
            Handle = new MyCriticalHandle()
            {
                Handle = handleValue1
            }
        };

        Assert.Throws <NotSupportedException>(() => Native.RefModify(handleValue2, ref handleStruct, null));
    }
示例#9
0
    public static void Ret()
    {
        IntPtr handleValue = MyCriticalHandle.GetUniqueHandle();

        Assert.Throws <MarshalDirectiveException>(() => Native.Ret(handleValue));
    }
示例#10
0
    public static void Ret()
    {
        IntPtr handleValue = MyCriticalHandle.GetUniqueHandle();

        Assert.Throws <NotSupportedException>(() => Native.Ret(handleValue));
    }