public void AllocateNewPageTest()
        {
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
            using (PageList target = new PageList(Globals.MemoryPool))
            {
                Assert.AreEqual(0, target.AllocateNewPage(0));
                Assert.AreEqual(Globals.MemoryPool.PageSize * 1, Globals.MemoryPool.AllocatedBytes);
                Assert.AreEqual(1, target.AllocateNewPage(2));
                Assert.AreEqual(Globals.MemoryPool.PageSize * 2, Globals.MemoryPool.AllocatedBytes);
                target.DoCollection(32, new HashSet<int>(new int[] { 1 }), GetEventArgs());
                Assert.AreEqual(Globals.MemoryPool.PageSize * 1, Globals.MemoryPool.AllocatedBytes);
                Assert.AreEqual(0, target.AllocateNewPage(0));
                Assert.AreEqual(2, target.AllocateNewPage(24352));

                Assert.AreNotEqual(IntPtr.Zero, target.GetPointerToPage(0, 0));
                Assert.AreNotEqual(IntPtr.Zero, target.GetPointerToPage(1, 0));
                Assert.AreNotEqual(IntPtr.Zero, target.GetPointerToPage(2, 0));
            }
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
        }
        unsafe public void PageMetaDataListConstructorTest()
        {
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);

            using (PageList target = new PageList(Globals.MemoryPool))
            {
                target.Dispose();
            }
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
            using (PageList target2 = new PageList(Globals.MemoryPool))
            {
                target2.AllocateNewPage(1);
                Assert.AreNotEqual(0, Globals.MemoryPool.AllocatedBytes);
            }

            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
        }
 public void DisposeTest()
 {
     Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
     using (PageList target = new PageList(Globals.MemoryPool))
     {
         target.AllocateNewPage(0);
         target.Dispose();
         Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
     }
 }
        public void DoCollectionTest()
        {
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);
            using (PageList target = new PageList(Globals.MemoryPool))
            {
                target.AllocateNewPage(0);
                target.AllocateNewPage(1);
                target.AllocateNewPage(2);
                target.AllocateNewPage(3);
                target.AllocateNewPage(4);
                target.AllocateNewPage(5);
                target.AllocateNewPage(6);
                target.AllocateNewPage(7);

                target.GetPointerToPage(0, 0);
                target.GetPointerToPage(1, 1 << 0);
                target.GetPointerToPage(2, 1 << 1);
                target.GetPointerToPage(3, 1 << 1);
                target.GetPointerToPage(4, 1 << 2);
                target.GetPointerToPage(5, 1 << 3);
                target.GetPointerToPage(6, 1 << 4);
                target.GetPointerToPage(7, 1 << 6);

                Assert.AreEqual(2, target.DoCollection(1, new HashSet<int>(), GetEventArgs()));
                Assert.AreEqual(2, target.DoCollection(1, new HashSet<int>(), GetEventArgs()));
                Assert.AreEqual(1, target.DoCollection(1, new HashSet<int>(), GetEventArgs()));
                Assert.AreEqual(1, target.DoCollection(1, new HashSet<int>(), GetEventArgs()));
                Assert.AreEqual(1, target.DoCollection(1, new HashSet<int>(), GetEventArgs()));
                Assert.AreEqual(0, target.DoCollection(1, new HashSet<int>(), GetEventArgs()));
                Assert.AreEqual(1, target.DoCollection(1, new HashSet<int>(), GetEventArgs()));
            }
            Assert.AreEqual(0, Globals.MemoryPool.AllocatedBytes);

        }