Пример #1
0
        public static unsafe void TestNullRefReturnOfPointer()
        {
            TestClassIntPointer tc = new TestClassIntPointer(null);

            PropertyInfo p = typeof(TestClassIntPointer).GetProperty(nameof(TestClassIntPointer.NullRefReturningProp));

            Assert.NotNull(p);
            Assert.Throws <NullReferenceException>(() => p.GetValue(tc));
        }
Пример #2
0
        public static unsafe void TestRefReturnOfPointer()
        {
            int *expected          = (int *)0x1122334455667788;
            TestClassIntPointer tc = new TestClassIntPointer(expected);
            PropertyInfo        p  = typeof(TestClassIntPointer).GetProperty(nameof(TestClassIntPointer.RefReturningProp));
            object rv = p.GetValue(tc);

            Assert.True(rv is Pointer);
            int *actual = (int *)(Pointer.Unbox(rv));

            Assert.Equal((IntPtr)expected, (IntPtr)actual);
        }