예제 #1
0
        public void GoToEnd()
        {
            string fileContent = "12345";
            string path        = $"{nameof(GoToEnd)}.txt";

            File.WriteAllText(path, fileContent);

            using (var fr = new TextFileScanner(path)) {
                fr.GoToEnd();

                Assert.AreEqual(fr.Line, 0);
                Assert.AreEqual(fr.Peek(), TextFileScanner.EOF);
                // + 2 to account for \r\n
                Assert.AreEqual(fr.Column, fileContent.Length + 2);
                Assert.IsFalse(fr.CanRead);
            }
            File.Delete(path);
        }
예제 #2
0
        public void GoPrevious()
        {
            string fileContent = "12345";
            string path        = $"{nameof(GoPrevious)}.txt";

            File.WriteAllText(path, fileContent);

            using (var fr = new TextFileScanner(path)) {
                fr.GoToEnd();
                // + 2 for \r\n
                for (int i = 0; i <= fileContent.Length + 2 - 1; i++)
                {
                    fr.GoPrevious();
                }
                Assert.AreEqual(fr.Line, 0);
                Assert.AreEqual(fr.Column, 0);
                Assert.IsTrue(fr.CanRead);
            }
            File.Delete(path);
        }