public void RemoveAtIndex_ThrowsIndexOutOfRangeException_1Point() { IIntegerList list = new IntegerList(); list.Add(11); list.RemoveAt(100); }
static void Main(string[] args) { IIntegerList list = new IntegerList(); list.Add(1); // [1] list.Add(2); // [1 ,2] list.Add(3); // [1 ,2 ,3] list.Add(4); // [1 ,2 ,3 ,4] list.Add(5); // [1 ,2 ,3 ,4 ,5] list.RemoveAt(0); // [2 ,3 ,4 ,5] list.Remove(4); //[2 ,3 ,4] Console.WriteLine(list.Count); // 3 Console.WriteLine(list.Remove(100)); // false Console.WriteLine(list.RemoveAt(5)); // false list.Clear(); // [] Console.WriteLine(list.Count); // 0 Console.Read(); }
public void RemoveAtIndex_1Point() { IIntegerList list = new IntegerList(); list.Add(11); Assert.AreEqual(true, list.RemoveAt(0)); Assert.AreEqual(0, list.Count); list.Add(11); list.Add(12); list.Add(13); Assert.AreEqual(true, list.RemoveAt(1)); Assert.AreEqual(2, list.Count); Assert.AreEqual(11, list.GetElement(0)); Assert.AreEqual(13, list.GetElement(1)); }