public void String() { string str = "Four score and seven years ago"; TextLineReader reader = new TextLineReader(str); Assert.IsNull(reader.SourceName); Assert.AreEqual(str, reader.ReadLine()); Assert.AreEqual(1, reader.LineNumber); AssertReaderAtEnd(reader); }
public void StringArray() { TextLineReader reader = new TextLineReader(array); Assert.IsNull(reader.SourceName); int expectedLineNum = 0; foreach (string str in array) { Assert.AreEqual(str, reader.ReadLine()); expectedLineNum++; Assert.AreEqual(expectedLineNum, reader.LineNumber); } AssertReaderAtEnd(reader); }
public void MultiLineText() { MultiLineText text = new MultiLineText(array); TextLineReader reader = new TextLineReader(text); Assert.IsNull(reader.SourceName); int expectedLineNum = 0; foreach (string line in text) { Assert.AreEqual(line, reader.ReadLine()); expectedLineNum++; Assert.AreEqual(expectedLineNum, reader.LineNumber); } AssertReaderAtEnd(reader); }
public void StringList() { List <string> list = new List <string>(array.Length); foreach (string str in array) { list.Add(str); } TextLineReader reader = new TextLineReader(list); Assert.IsNull(reader.SourceName); int expectedLineNum = 0; foreach (string str in list) { Assert.AreEqual(str, reader.ReadLine()); expectedLineNum++; Assert.AreEqual(expectedLineNum, reader.LineNumber); } AssertReaderAtEnd(reader); }
//--------------------------------------------------------------------- private void AssertReaderAtEnd(TextLineReader reader) { Assert.IsNull(reader.ReadLine()); Assert.AreEqual(reader.LineNumber, LineReader.EndOfInput); }