public void LastIndexOf_int_OutOfRangeExceptions(int count)
        {
            PooledList <T> list = GenericListFactory(count);
            T element           = CreateT(234);

            Assert.Throws <ArgumentOutOfRangeException>(() => list.LastIndexOf(element, count)); //"ArgumentOutOfRangeException expected."
            if (count == 0)                                                                      // IndexOf with a 0 count List is special cased to return -1.
            {
                Assert.Equal(-1, list.LastIndexOf(element, -1));
            }
            else
            {
                Assert.Throws <ArgumentOutOfRangeException>(() => list.LastIndexOf(element, -1));
            }
            list.Dispose();
        }
        public void LastIndexOf_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.LastIndexOf(withoutDuplicates[i], (count * (j + 1)) - 1));
                    Assert.Equal(expectedIndex, list.LastIndexOf(withoutDuplicates[i], (count * (j + 1)) - 1, count));
                });
            });

            list.Dispose();
            withoutDuplicates.Dispose();
        }
        public void LastIndexOf_int_int_OutOfRangeExceptions(int count)
        {
            PooledList <T> list = GenericListFactory(count);
            T element           = CreateT(234);

            if (count > 0)
            {
                Assert.Throws <ArgumentOutOfRangeException>(() => list.LastIndexOf(element, 0, count + 1));             //"Expected ArgumentOutOfRangeException."
                Assert.Throws <ArgumentOutOfRangeException>(() => list.LastIndexOf(element, count / 2, count / 2 + 2)); //"Expected ArgumentOutOfRangeException."
                Assert.Throws <ArgumentOutOfRangeException>(() => list.LastIndexOf(element, 0, count + 1));             //"Expected ArgumentOutOfRangeException."
                Assert.Throws <ArgumentOutOfRangeException>(() => list.LastIndexOf(element, 0, -1));                    //"Expected ArgumentOutOfRangeException."
                Assert.Throws <ArgumentOutOfRangeException>(() => list.LastIndexOf(element, -1, count));                //"Expected ArgumentOutOfRangeException."
                Assert.Throws <ArgumentOutOfRangeException>(() => list.LastIndexOf(element, -1, 1));                    //"Expected ArgumentOutOfRangeException."                Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, count, 0)); //"Expected ArgumentOutOfRangeException."
                Assert.Throws <ArgumentOutOfRangeException>(() => list.LastIndexOf(element, count, 1));                 //"Expected ArgumentOutOfRangeException."
            }
            else // IndexOf with a 0 count List is special cased to return -1.
            {
                Assert.Equal(-1, list.LastIndexOf(element, 0, count + 1));
                Assert.Equal(-1, list.LastIndexOf(element, count / 2, count / 2 + 2));
                Assert.Equal(-1, list.LastIndexOf(element, 0, count + 1));
                Assert.Equal(-1, list.LastIndexOf(element, 0, -1));
                Assert.Equal(-1, list.LastIndexOf(element, -1, count));
                Assert.Equal(-1, list.LastIndexOf(element, -1, 1));
                Assert.Equal(-1, list.LastIndexOf(element, count, 0));
                Assert.Equal(-1, list.LastIndexOf(element, count, 1));
            }

            list.Dispose();
        }