public void Stack_Generic_Pop_AllElements(int count) { PooledStack <T> stack = GenericStackFactory(count); List <T> elements = stack.ToList(); foreach (T element in elements) { Assert.Equal(element, stack.Pop()); } }
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_TryPop_AllElements(int count) { PooledStack <T> stack = GenericStackFactory(count); List <T> elements = stack.ToList(); foreach (T element in elements) { Assert.True(stack.TryPop(out T result)); Assert.Equal(element, result); } }
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); } }