Ejemplo n.º 1
0
 public static void CriticalHandle_valid_close()
 {
     MyCriticalHandle mch = new MyCriticalHandle(new IntPtr(1));
     mch.Close();
     Assert.True(mch.IsClosed);
     Assert.False(mch.IsInvalid);
     Assert.True(mch.IsReleased);
 }
Ejemplo n.º 2
0
    public static void CriticalHandle_invalid()
    {
        MyCriticalHandle mch = new MyCriticalHandle();
        Assert.False(mch.IsClosed);
        Assert.True(mch.IsInvalid);
        Assert.False(mch.IsReleased);

        mch.Dispose();
        Assert.True(mch.IsClosed);
        Assert.True(mch.IsInvalid);
        Assert.False(mch.IsReleased);
    }
Ejemplo n.º 3
0
 public static void CriticalHandle_valid()
 {
     MyCriticalHandle mch = new MyCriticalHandle(new IntPtr(1));
     Assert.Equal(false, mch.IsClosed);
     Assert.Equal(false, mch.IsInvalid);
 }
Ejemplo n.º 4
0
 public static void CriticalHandle_invalid()
 {
     MyCriticalHandle mch = new MyCriticalHandle();
     Assert.Equal(false, mch.IsClosed);
     Assert.Equal(true, mch.IsInvalid);
 }
Ejemplo n.º 5
0
    private static void RetWorker(IntPtr handleValue)
    {
        MyCriticalHandle hande = Native.Ret(handleValue);

        Assert.AreEqual(handleValue.ToInt32(), hande.Handle.ToInt32(), "Handle value");
    }
Ejemplo n.º 6
0
 internal static extern IntPtr RefModify(IntPtr handleValue, ref MyCriticalHandle handle, HandleCallback handleCallback);
Ejemplo n.º 7
0
 internal static extern IntPtr Ref(ref MyCriticalHandle handle, HandleCallback handleCallback);
Ejemplo n.º 8
0
 internal static extern void Out(IntPtr handleValue, out MyCriticalHandle handle);
Ejemplo n.º 9
0
 internal static extern IntPtr In(MyCriticalHandle handle, HandleCallback handleCallback);
Ejemplo n.º 10
0
    public static void Ret()
    {
        IntPtr handleValue = MyCriticalHandle.GetUniqueHandle();

        Assert.Throws <NotSupportedException>(() => Native.Ret(handleValue));
    }
Ejemplo n.º 11
0
 static extern void SomeMethodTakingCriticalHandle(MyCriticalHandle handle);
Ejemplo n.º 12
0
    public static void Ret()
    {
        IntPtr handleValue = MyCriticalHandle.GetUniqueHandle();

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