public void InsertRangeValidations(T[] items, Func <T[], IEnumerable <T> > constructIEnumerable) { var list = new DoublyCircularLinkedList <T>(constructIEnumerable(items)); var bad = new int[] { items.Length + 1, items.Length + 2, int.MaxValue, -1, -2, int.MinValue }; for (var i = 0; i < bad.Length; i++) { Assert.Throws <ArgumentOutOfRangeException>(() => list.InsertRange(bad[i], constructIEnumerable(items))); //"ArgumentOutOfRangeException expected" } Assert.Throws <ArgumentNullException>(() => list.InsertRange(0, null)); //"ArgumentNullException expected." }
public void InsertRangeList(T[] itemsX, T[] itemsY, int index, int repeat, Func <T[], IEnumerable <T> > constructIEnumerable) { var list = new DoublyCircularLinkedList <T>(constructIEnumerable(itemsX)); for (var i = 0; i < repeat; i++) { list.InsertRange(index, new DoublyCircularLinkedList <T>(constructIEnumerable(itemsY))); } foreach (var item in itemsY) { Assert.Contains(item, list); //"Should contain the item." } Assert.Equal(list.Count, itemsX.Length + (itemsY.Length * repeat)); //"Should have the same result." for (var i = 0; i < index; i++) { Assert.Equal(list[i], itemsX[i]); //"Should have the same result." } for (var i = index; i < index + (itemsY.Length * repeat); i++) { Assert.Equal(list[i], itemsY[(i - index) % itemsY.Length]); //"Should have the same result." } for (var i = index + (itemsY.Length * repeat); i < list.Count; i++) { Assert.Equal(list[i], itemsX[i - (itemsY.Length * repeat)]); //"Should have the same result." } }