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); }
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); }
public static void CriticalHandle_valid() { MyCriticalHandle mch = new MyCriticalHandle(new IntPtr(1)); Assert.Equal(false, mch.IsClosed); Assert.Equal(false, mch.IsInvalid); }
public static void CriticalHandle_invalid() { MyCriticalHandle mch = new MyCriticalHandle(); Assert.Equal(false, mch.IsClosed); Assert.Equal(true, mch.IsInvalid); }
private static void RetWorker(IntPtr handleValue) { MyCriticalHandle hande = Native.Ret(handleValue); Assert.AreEqual(handleValue.ToInt32(), hande.Handle.ToInt32(), "Handle value"); }
internal static extern IntPtr RefModify(IntPtr handleValue, ref MyCriticalHandle handle, HandleCallback handleCallback);
internal static extern IntPtr Ref(ref MyCriticalHandle handle, HandleCallback handleCallback);
internal static extern void Out(IntPtr handleValue, out MyCriticalHandle handle);
internal static extern IntPtr In(MyCriticalHandle handle, HandleCallback handleCallback);
public static void Ret() { IntPtr handleValue = MyCriticalHandle.GetUniqueHandle(); Assert.Throws <NotSupportedException>(() => Native.Ret(handleValue)); }
static extern void SomeMethodTakingCriticalHandle(MyCriticalHandle handle);
public static void Ret() { IntPtr handleValue = MyCriticalHandle.GetUniqueHandle(); Assert.Throws <MarshalDirectiveException>(() => Native.Ret(handleValue)); }