Esempio n. 1
0
 private void EmulateLog(string sourceFilePath, string targetFilePath)
 {
     using (var logger = new LoggerEmulator(sourceFilePath, targetFilePath))
     {
         logger.WriteToEnd();
     }
 }
Esempio n. 2
0
        public void ShouldDetectNewWrite()
        {
            const int LogFileLineCount = 9;

            string[] newLines = testData.CreateLogLines(1);

            var tempDir      = TestData.CreateTempDirectory();
            var tempFileName = Path.Combine(tempDir, "log.log");

            Debug.WriteLine(tempFileName);
            using (var watcher = new Watcher())
            {
                using (var stringWriter = new StringWriter())
                {
                    var      writer = new LineTextWriter(stringWriter);
                    string[] writtenLines;
                    using (var logger = new LoggerEmulator(logFile9, tempFileName))
                    {
                        logger.WriteToEnd();

                        watcher.LineWriter    = writer;
                        watcher.DirectoryPath = tempDir;
                        watcher.Filter        = "*.log";
                        watcher.LineCount     = 4;
                        watcher.Start();
                        Thread.Sleep(200);
                        logger.WriteLines(newLines);
                    }

                    Thread.Sleep(1000);
                    watcher.Stop();
                    writer.Flush();
                    writtenLines = stringWriter.ToString().ToLines();

                    var expectedLines = CreateLineListWithFileMarker(
                        TestData.LoadLines(logFile9,
                                           LogFileLineCount - watcher.LineCount,
                                           watcher.LineCount));
                    expectedLines.AddRange(newLines);
                    CompareLines(expectedLines.ToArray(), writtenLines);
                }
            }
        }
Esempio n. 3
0
        public void ShouldDetectNewWrite()
        {
            const int LogFileLineCount = 9;
            string[] newLines = testData.CreateLogLines(1);

            var tempDir = TestData.CreateTempDirectory();
            var tempFileName = Path.Combine(tempDir, "log.log");
            Debug.WriteLine(tempFileName);
            using (var watcher = new Watcher())
            {
                using (var stringWriter = new StringWriter())
                {
                    var writer = new LineTextWriter(stringWriter);
                    string[] writtenLines;
                    using (var logger = new LoggerEmulator(logFile9, tempFileName))
                    {
                        logger.WriteToEnd();

                        watcher.LineWriter = writer;
                        watcher.DirectoryPath = tempDir;
                        watcher.Filter = "*.log";
                        watcher.LineCount = 4;
                        watcher.Start();
                        Thread.Sleep(200);
                        logger.WriteLines(newLines);
                    }

                    Thread.Sleep(1000);
                    watcher.Stop();
                    writer.Flush();
                    writtenLines = stringWriter.ToString().ToLines();

                    var expectedLines = CreateLineListWithFileMarker(
                        TestData.LoadLines(logFile9,
                                           LogFileLineCount - watcher.LineCount,
                                           watcher.LineCount));
                    expectedLines.AddRange(newLines);
                    CompareLines(expectedLines.ToArray(), writtenLines);
                }
            }
        }
Esempio n. 4
0
 private void EmulateLog(string sourceFilePath, string targetFilePath)
 {
     using (var logger = new LoggerEmulator(sourceFilePath, targetFilePath))
     {
         logger.WriteToEnd();
     }
 }