public void NotFreeTheMemoryAllocatedIfPtrIsZero() { var target = new StubStructMarshallingService(); target.FreeHGlobalIfNeeded(IntPtr.Zero); Assert.IsFalse(target.ReleasedUnmanagedMemory); }
public void FreeTheMemoryAllocated() { var result = IntPtr.Zero; var target = new StubStructMarshallingService(); try { result = Marshal.AllocHGlobal(4); Assert.AreNotEqual(IntPtr.Zero, result); } finally { target.FreeHGlobalIfNeeded(result); Assert.IsTrue(target.ReleasedUnmanagedMemory); } }