예제 #1
0
        public void MethodDelegateParameter_SystemPointer(int value)
        {
            var obj = new PointerHolder();
            MethodDelegateWithSystemPointer d = obj.MethodWithSystemPointer;

            d.DynamicInvoke(Pointer.Box(unchecked ((void *)value), typeof(byte *)), value);
        }
예제 #2
0
        public void PointerMethodDelegateParameter_InvalidType_SystemPointer(int value)
        {
            // Although the type boxed doesn't match, when unboxing void* is returned.
            var obj = new PointerHolder();
            MethodDelegateWithSystemPointer d = obj.MethodWithSystemPointer;

            d.DynamicInvoke(Pointer.Box(unchecked ((void *)value), typeof(long *)), value);
        }
예제 #3
0
        public void IntPtrMethodDelegateParameter_InvalidType_SystemPointer(int value)
        {
            // An IntPtr is not converted to a System.Pointer.
            var obj = new PointerHolder();
            MethodDelegateWithSystemPointer d = obj.MethodWithSystemPointer;

            AssertExtensions.Throws <ArgumentException>(null, () =>
            {
                d.DynamicInvoke((IntPtr)value, value);
            });
        }
예제 #4
0
        public void PointerNullMethodDelegateParameter_InvalidType_SystemPointer()
        {
            // An null is not converted to a System.Pointer.
            var obj = new PointerHolder();
            MethodDelegateWithSystemPointer d = obj.MethodWithSystemPointer;

            try
            {
                d.DynamicInvoke(null, 0);
            }
            catch (TargetInvocationException e) when(e.InnerException is ArgumentException)
            {
                return;
            }

            Assert.Fail("Inner exception should be ArgumentException.");
        }