public void RemoveRange_InvalidParameters(int listLength) { if (listLength % 2 != 0) { listLength++; } SegmentedList <T> list = GenericListFactory(listLength); Tuple <int, int>[] InvalidParameters = new Tuple <int, int>[] { Tuple.Create(listLength, 1), Tuple.Create(listLength + 1, 0), Tuple.Create(listLength + 1, 1), Tuple.Create(listLength, 2), Tuple.Create(listLength / 2, listLength / 2 + 1), Tuple.Create(listLength - 1, 2), Tuple.Create(listLength - 2, 3), Tuple.Create(1, listLength), Tuple.Create(0, listLength + 1), Tuple.Create(1, listLength + 1), Tuple.Create(2, listLength), Tuple.Create(listLength / 2 + 1, listLength / 2), Tuple.Create(2, listLength - 1), Tuple.Create(3, listLength - 2), }; Assert.All(InvalidParameters, invalidSet => { if (invalidSet.Item1 >= 0 && invalidSet.Item2 >= 0) { Assert.Throws <ArgumentException>(null, () => list.RemoveRange(invalidSet.Item1, invalidSet.Item2)); } }); }
public void RemoveRange_NegativeParameters(int listLength) { if (listLength % 2 != 0) { listLength++; } SegmentedList <T> list = GenericListFactory(listLength); Tuple <int, int>[] InvalidParameters = new Tuple <int, int>[] { Tuple.Create(-1, -1), Tuple.Create(-1, 0), Tuple.Create(-1, 1), Tuple.Create(-1, 2), Tuple.Create(0, -1), Tuple.Create(1, -1), Tuple.Create(2, -1), }; Assert.All( InvalidParameters, invalidSet => { Assert.Throws <ArgumentOutOfRangeException>( () => list.RemoveRange(invalidSet.Item1, invalidSet.Item2) ); } ); }
public void Remove_Range(int listLength, int index, int count) { SegmentedList <T> list = GenericListFactory(listLength); SegmentedList <T> beforeList = list.ToSegmentedList(); list.RemoveRange(index, count); Assert.Equal(list.Count, listLength - count); //"Expected them to be the same." for (int i = 0; i < index; i++) { Assert.Equal(list[i], beforeList[i]); //"Expected them to be the same." } for (int i = index; i < count - (index + count); i++) { Assert.Equal(list[i], beforeList[i + count]); //"Expected them to be the same." } }