예제 #1
0
        public void DeletingSomeLines()
        {
            const int totalLines = 10000;

            var filename       = Path.Combine(Path.GetTempPath(), string.Format("{0}.txt", DateTime.Now.Ticks));
            var lineFileWriter = new LineFile(filename);

            var linesToAdd = new List <string>();

            for (int i = 0; i < totalLines; i++)
            {
                linesToAdd.Add(string.Format("This is a medium lenght line, and, incidentally, this is the {0} line :)", i));
            }
            lineFileWriter.AddLines(linesToAdd.ToArray());

            var linesToDelete = new List <string>();

            for (int i = 0; i < totalLines; i += 10)
            {
                linesToDelete.Add(string.Format("This is a medium lenght line, and, incidentally, this is the {0} line :)", i));
            }
            lineFileWriter.DeleteLines(linesToDelete.ToArray());

            var readLines = lineFileWriter.ReadAllLines();

            Assert.AreEqual(totalLines - (totalLines / 10), readLines.Count);
        }
예제 #2
0
        public void AddingTooMuchLines()
        {
            var filename       = Path.Combine(Path.GetTempPath(), string.Format("{0}.txt", DateTime.Now.Ticks));
            var lineFileWriter = new LineFile(filename);

            var lines = new List <string>();

            for (int i = 0; i < 1000000; i++)
            {
                lines.Add(string.Format("This is a medium lenght line, and, incidentally, this is the {0} line :)", i));
            }
            lineFileWriter.AddLines(lines.ToArray());

            Assert.IsTrue(File.Exists(filename));
        }
예제 #3
0
        public void ReadLine(int number)
        {
            var filename       = Path.Combine(Path.GetTempPath(), string.Format("{0}.txt", DateTime.Now.Ticks));
            var lineFileWriter = new LineFile(filename);

            var lines = new List <string>();

            for (int i = 0; i < 1000; i++)
            {
                lines.Add(i.ToString());
            }
            lineFileWriter.AddLines(lines.ToArray());

            var line = lineFileWriter.ReadLine(number);

            Assert.AreEqual(number.ToString(), line);
        }
예제 #4
0
        public void ReadAllLines()
        {
            var filename       = Path.Combine(Path.GetTempPath(), string.Format("{0}.txt", DateTime.Now.Ticks));
            var lineFileWriter = new LineFile(filename);

            var lines = new List <string>();

            for (int i = 0; i < 1000000; i++)
            {
                lines.Add(string.Format("This is a medium lenght line, and, incidentally, this is the {0} line :)", i));
            }
            lineFileWriter.AddLines(lines.ToArray());

            var readLines = lineFileWriter.ReadAllLines();

            Assert.AreEqual(1000000, readLines.Count);
        }