public void IndexOf_int_OutOfRangeExceptions(int count) { PooledList <T> list = GenericListFactory(count); T element = CreateT(234); Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, count + 1)); //"Expect ArgumentOutOfRangeException for index greater than length of list.." Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, count + 10)); //"Expect ArgumentOutOfRangeException for index greater than length of list.." Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, -1)); //"Expect ArgumentOutOfRangeException for negative index." Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, int.MinValue)); //"Expect ArgumentOutOfRangeException for negative index." list.Dispose(); }
public void IndexOf_int_OrderIsCorrectWithManyDuplicates(int count) { PooledList <T> list = GenericListFactory(count); PooledList <T> withoutDuplicates = list.ToPooledList(); list.AddRange(list); list.AddRange(list); list.AddRange(list); Assert.All(Enumerable.Range(0, count), i => { Assert.All(Enumerable.Range(0, 4), j => { int expectedIndex = (j * count) + i; Assert.Equal(expectedIndex, list.IndexOf(withoutDuplicates[i], (count * j))); Assert.Equal(expectedIndex, list.IndexOf(withoutDuplicates[i], (count * j), count)); }); }); list.Dispose(); withoutDuplicates.Dispose(); }
public void IndexOf_int_int_OutOfRangeExceptions(int count) { PooledList <T> list = GenericListFactory(count); T element = CreateT(234); Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, count, 1)); //"ArgumentOutOfRangeException expected on index larger than array." Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, count + 1, 1)); //"ArgumentOutOfRangeException expected on index larger than array." Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, 0, count + 1)); //"ArgumentOutOfRangeException expected on count larger than array." Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, count / 2, count / 2 + 2)); //"ArgumentOutOfRangeException expected.." Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, 0, count + 1)); //"ArgumentOutOfRangeException expected on count larger than array." Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, 0, -1)); //"ArgumentOutOfRangeException expected on negative count." Assert.Throws <ArgumentOutOfRangeException>(() => list.IndexOf(element, -1, 1)); //"ArgumentOutOfRangeException expected on negative index." list.Dispose(); }