public void RemoveAll_DefaultElements(int count) { PooledList <T> list = GenericListFactory(count); PooledList <T> beforeList = list.ToPooledList(); bool EqualsDefaultElement(T value) { return(default(T) == null ? value == null : default(T).Equals(value)); } int expectedCount = beforeList.Count((value) => EqualsDefaultElement(value)); int removedCount = list.RemoveAll(EqualsDefaultElement); Assert.Equal(expectedCount, removedCount); list.Dispose(); beforeList.Dispose(); }
public void BinarySearch_ForEveryItemWithoutDuplicates(int count) { PooledList <T> list = GenericListFactory(count); foreach (T item in list) { while (list.Count((value) => value.Equals(item)) > 1) { list.Remove(item); } } list.Sort(); PooledList <T> beforeList = list.ToPooledList(); Assert.All(Enumerable.Range(0, list.Count), index => { Assert.Equal(index, list.BinarySearch(beforeList[index])); Assert.Equal(index, list.BinarySearch(beforeList[index], GetIComparer())); Assert.Equal(beforeList[index], list[index]); }); list.Dispose(); }