public void ReadFileContent() { string fileContent = "12345"; string path = $"{nameof(ReadFileContent)}.txt"; File.WriteAllText(path, fileContent); using (var fr = new TextFileScanner(path)) { for (int i = 0; i < fileContent.Length; i++) { char c = fr.Read(); Assert.AreEqual(c, fileContent[i]); } // Two extra reads for the ending /r/n fr.Read(); fr.Read(); Assert.IsFalse(fr.CanRead); } File.Delete(path); }
public void GoToStart() { string fileContent = "12345"; string path = $"{nameof(GoToStart)}.txt"; File.WriteAllText(path, fileContent); using (var fr = new TextFileScanner(path)) { while (fr.CanRead) { fr.Read(); } fr.GoToStart(); Assert.IsTrue(fr.CanRead); } File.Delete(path); }
public void ReadMultiLine() { string fileContent = @"1 2 3 4"; string path = $"{nameof(ReadMultiLine)}.txt"; File.WriteAllText(path, fileContent); int count = 0; using (var fr = new TextFileScanner(path)) { while (fr.CanRead) { fr.Read(); count++; } } File.Delete(path); // + 2 to account for the last \r\n Assert.AreEqual(fileContent.Length + 2, count); }