public void ThrowsIndexOutOfRange() { var list = new SimpleArrayList <int>(1); list.Add(1); list.Add(2); }
public void ToStringReturnsOnlySetValues() { var list = new SimpleArrayList <int>(4); list.Add(1); list.Add(2); Assert.AreEqual("1,2", list.ToString()); }
public void ToStringReturnsCommaSeparated() { var list = new SimpleArrayList <int>(2); list.Add(1); list.Add(2); Assert.AreEqual("1,2", list.ToString()); }
public void CountOccurencesReturnsCorrectNumber() { var list = new SimpleArrayList <int>(3); list.Add(1); list.Add(3); list.Add(1); Assert.AreEqual(2, list.CountOccurences(1)); }
public void ClearArray() { var list = new SimpleArrayList <int>(2); list.Add(3); list.Add(4); Assert.AreEqual("3,4", list.ToString()); list.Clear(); Assert.AreEqual("", list.ToString()); }
public void ReturnsDataAtIndex() { var list = new SimpleArrayList <int>(1); list.Add(2); Assert.AreEqual(list.Get(0), 2); }
// Read an unlimited number of String; return an ArrayList public static SimpleArrayList GetStrings( ) { SimpleArrayList array = new SimpleArrayList( ); string oneLine; Console.WriteLine("Enter any number of strings, one per line; "); Console.WriteLine("Terminate with empty line: "); try { while ((oneLine = Console.ReadLine( )) != null && oneLine != "") { array.Add(oneLine); } } catch (IOException) { Console.WriteLine("Unexpected IO Exception has shortened amount read"); } Console.WriteLine("Done reading"); return(array); }