public void BasicInsert(T[] items, T item, int index, int repeat) { var list = new DoublyCircularLinkedList <T>(items); for (var i = 0; i < repeat; i++) { list.Insert(index, item); } Assert.Contains(item, list); //"Expect it to contain the item." Assert.Equal(list.Count, items.Length + repeat); //"Expect to be the same." for (var i = 0; i < index; i++) { Assert.Equal(list[i], items[i]); //"Expect to be the same." } for (var i = index; i < index + repeat; i++) { Assert.Equal(list[i], item); //"Expect to be the same." } for (var i = index + repeat; i < list.Count; i++) { Assert.Equal(list[i], items[i - repeat]); //"Expect to be the same." } }
public void InsertValidations(T[] items) { var list = new DoublyCircularLinkedList <T>(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.Insert(bad[i], items[0])); //"ArgumentOutOfRangeException expected." } }