public static void Insert_EndIndex() { const int itemsToInsert = 5; var collection = new ModifiableCollection <int>(s_intArray); for (int i = 0; i < itemsToInsert; i++) { collection.Insert(collection.Count, i); } for (int i = 0; i < itemsToInsert; i++) { Assert.Equal(i, collection[s_intArray.Length + i]); } }
public static void Indexer() { var collection = new ModifiableCollection <int>(s_intArray); for (int i = 0; i < s_intArray.Length; i++) { collection[i] = i; Assert.Equal(i, collection[i]); } Assert.Throws <ArgumentOutOfRangeException>(() => { var x = collection[-1]; }); Assert.Throws <ArgumentOutOfRangeException>(() => { var x = collection[s_intArray.Length]; }); Assert.Throws <ArgumentOutOfRangeException>(() => { var x = s_empty[0]; }); Assert.Throws <ArgumentOutOfRangeException>(() => { collection[-1] = 0; }); Assert.Throws <ArgumentOutOfRangeException>(() => { collection[s_intArray.Length] = 0; }); }