Exemplo n.º 1
0
        public void FileWatcherTestMethod()
        {
            FileWatcher watcher = ArrangeFileWatcher();

            Thread.Sleep(4000);
            WriteNewLineToFile();
            Thread.Sleep(4000);
            MasterLogger m_logger = CreateMasterLogger();
            string       consolidatedLogFilePath = @"C:\Windows\Temp\consolidated log\consolidatedLog.log";

            FileStream   fs      = new FileStream(consolidatedLogFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            StreamReader sReader = new StreamReader(fs, Encoding.UTF8);
            string       line;
            string       lastLine = "";

            while ((line = sReader.ReadLine()) != null)
            {
                lastLine = line;
            }

            string expectedJsonString = JsonConvert.SerializeObject(m_logger);

            watcher.Finish();
            Assert.AreEqual(lastLine, expectedJsonString);
        }