Ejemplo n.º 1
0
        public void ReturnsNullWhenTheSizeIsZero()
        {
            var target = new MarshallingService();
            var result = target.AllocHGlobal(0);

            Assert.AreEqual(IntPtr.Zero, result);
        }
Ejemplo n.º 2
0
        public void AllocateThePointerSpecified()
        {
            var result = IntPtr.Zero;

            try
            {
                var target = new MarshallingService();
                result = target.AllocHGlobal(4);

                Assert.AreNotEqual(IntPtr.Zero, result);
            }
            finally
            {
                if (result != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(result);
                }
            }
        }
Ejemplo n.º 3
0
        public void ThrowsAnExceptionWhenTheSizeIsLessThanZero()
        {
            var target = new MarshallingService();

            Assert.Throws <ArgumentException>(() => target.AllocHGlobal(0));
        }