public void HashSet_Generic_TrimExcess_Repeatedly(int setLength) { PooledSet <T> set = (PooledSet <T>)GenericISetFactory(setLength); List <T> expected = set.ToList(); set.TrimExcess(); set.TrimExcess(); set.TrimExcess(); Assert.True(set.SetEquals(expected)); }
public void HashSet_Generic_TrimExcess_AfterClearingAndAddingAllElementsBack(int setLength) { if (setLength > 0) { PooledSet <T> set = (PooledSet <T>)GenericISetFactory(setLength); set.TrimExcess(); set.Clear(); set.TrimExcess(); Assert.Equal(0, set.Count); AddToCollection(set, setLength); set.TrimExcess(); Assert.Equal(setLength, set.Count); } }
public void HashSet_Generic_TrimExcess_AfterRemovingOneElement(int setLength) { if (setLength > 0) { PooledSet <T> set = (PooledSet <T>)GenericISetFactory(setLength); List <T> expected = set.ToList(); T elementToRemove = set.ElementAt(0); set.TrimExcess(); Assert.True(set.Remove(elementToRemove)); expected.Remove(elementToRemove); set.TrimExcess(); Assert.True(set.SetEquals(expected)); } }
public void HashSet_Generic_TrimExcess_OnValidSetThatHasntBeenRemovedFrom(int setLength) { PooledSet <T> set = (PooledSet <T>)GenericISetFactory(setLength); set.TrimExcess(); }