Пример #1
0
        public void Pin()
        {
            var array = new byte[] { 31, 33, 7 };
            var span  = new Span <byte>(array);

            fixed(byte *ptr = array)
            {
                var mgr = new UnmanagedPointerMemoryManager <byte>(span);

                using (var handle00 = mgr.Pin())
                    using (var handle01 = mgr.Pin(1))
                    {
                        Assert.Equal((ulong)ptr, (ulong)handle00.Pointer);
                        Assert.Equal((ulong)(ptr + 1), (ulong)handle01.Pointer);
                    }
            }
        }
Пример #2
0
        public void Pin_throw_ArgumentOutOfRangeException()
        {
            var array = new byte[] { 31, 33, 7 };
            var span  = new Span <byte>(array);

            fixed(byte *ptr = array)
            {
                var mgr = new UnmanagedPointerMemoryManager <byte>(span);

                Assert.Throws <ArgumentOutOfRangeException>(() => mgr.Pin(-1));
            }
        }