Пример #1
0
        public void DeleteAll()
        {
            MonitoredUnmanagedMemory mem = new MonitoredUnmanagedMemory();

            XorLinkedList list = new XorLinkedList(mem);

            list.Append(1);
            list.Append(2);
            list.Append(3);

            list.DeleteAll();

            Assert.Empty(mem.currentAllocations);
        }
Пример #2
0
        public void AllocationFreeing()
        {
            MonitoredUnmanagedMemory mem  = new MonitoredUnmanagedMemory();
            XorLinkedList            list = new XorLinkedList(mem);

            list.Append(1);
            list.Append(2);
            list.Append(3);
            list.RemoveAt(0);
            Assert.Equal(2, mem.currentAllocations.Count);
            list.RemoveAt(0);
            Assert.Single(mem.currentAllocations);
            list.RemoveAt(0);
            Assert.Empty(mem.currentAllocations);
        }
Пример #3
0
        public void ResponsiveToGarbageCollection()
        {
            MonitoredUnmanagedMemory mem = new MonitoredUnmanagedMemory();

            void innerScope()
            {
                XorLinkedList list = new XorLinkedList(mem);

                list.Append(1);
                list.Append(2);
                list.Append(3);
                Assert.Equal(3, mem.currentAllocations.Count);
            }

            innerScope();

            GC.Collect();
            GC.WaitForPendingFinalizers();
            Assert.Empty(mem.currentAllocations);
        }