Example #1
0
        public void Stack_Generic_TrimExcess_Repeatedly(int count)
        {
            PooledStack <T> stack    = GenericStackFactory(count);
            List <T>        expected = stack.ToList();

            stack.TrimExcess();
            stack.TrimExcess();
            stack.TrimExcess();
            Assert.Equal(expected, stack);
        }
Example #2
0
        public void Stack_Generic_TrimExcess_AfterClearingAndAddingAllElementsBack(int count)
        {
            if (count > 0)
            {
                PooledStack <T> stack = GenericStackFactory(count);
                stack.TrimExcess();
                stack.Clear();
                stack.TrimExcess();
                Assert.Equal(0, stack.Count);

                AddToCollection(stack, count);
                stack.TrimExcess();
                Assert.Equal(count, stack.Count);
            }
        }
Example #3
0
        public void Stack_Generic_TrimExcess_AfterRemovingOneElement(int count)
        {
            if (count > 0)
            {
                PooledStack <T> stack    = GenericStackFactory(count);
                List <T>        expected = stack.ToList();
                T elementToRemove        = stack.ElementAt(0);

                stack.TrimExcess();
                stack.Pop();
                expected.RemoveAt(0);
                stack.TrimExcess();

                Assert.Equal(expected, stack);
            }
        }
Example #4
0
        public void Stack_Generic_TrimExcess_OnValidStackThatHasntBeenRemovedFrom(int count)
        {
            PooledStack <T> stack = GenericStackFactory(count);

            stack.TrimExcess();
        }