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); }
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); } }
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); } }
public void Stack_Generic_TrimExcess_OnValidStackThatHasntBeenRemovedFrom(int count) { PooledStack <T> stack = GenericStackFactory(count); stack.TrimExcess(); }