Example #1
0
        public void RolledFilesNoPosition()
        {
            string testDir = Path.Combine(BaseDir, "RolledFilesWithoutPosition");
            var    path    = Path.Combine(testDir, "aFile.txt");

            var    filePositionStoreMock = new Mock <IFilePositionStore>();
            var    fileReader            = new RollingFileReader(path, filePositionStoreMock.Object, ReadBehaviour.FromBeginning);
            string text = fileReader.ReadAllText();

            BaseLineAssert.AreEqual(Path.Combine(testDir, "expected.txt"), text);
        }
Example #2
0
        public void RolledFilesWithPosition()
        {
            string testDir = Path.Combine(BaseDir, "RolledFilesWithPosition");

            var path = Path.Combine(testDir, "aFile.txt");

            FilePosition position;

            using (var stream = FileUtils.OpenFileStreamForReading(Path.Combine(testDir, "_aFile.txt")))
                using (var reader = new StreamReader(stream))
                {
                    position = FilePositionSerialiser.Read(path, reader);
                }
            var filePositionStoreMock = new Mock <IFilePositionStore>();

            filePositionStoreMock.Setup(_ => _.GetPosition(path)).Returns(position);
            var    fileReader = new RollingFileReader(path, filePositionStoreMock.Object, ReadBehaviour.FromWhereLeft);
            string text       = fileReader.ReadAllText();

            BaseLineAssert.AreEqual(Path.Combine(testDir, "expected.txt"), text);
        }