Exemplo n.º 1
0
        public void LogFileFinderValidFilesAreOnlyReadOnce()
        {
            var fs = new ApplicationLogsTestFileSystem();

            FileSystemHelpers.Instance = fs;
            fs.AddLogFile("log-1.txt",
                          @"2013-12-06T00:29:20  PID[20108] Information this is a log
2013-12-06T00:29:21  PID[20108] Warning     this is a warning
2013-12-06T00:29:22  PID[20108] Error       this is an error"
                          );

            var stats      = new ApplicationLogsReader.LogFileAccessStats();
            var env        = new ApplicationLogsTestEnvironment();
            var fileFinder = new ApplicationLogsReader.LogFileFinder(env, Mock.Of <ITracer>(), stats);

            fileFinder.FindLogFiles();

            fs.AddLogFile("log-2.txt", @"2013-12-06T00:29:20  PID[20108] Information this is a log");
            fileFinder.FindLogFiles();

            fs.AddLogFile("log-3.txt", @"2013-12-06T00:29:20  PID[20108] Information this is a log");
            var results = fileFinder.FindLogFiles().ToList();

            Assert.Equal(3, results.Count);
            Assert.Equal(1, stats.GetOpenTextCount("log-1.txt"));
            Assert.Equal(1, stats.GetOpenTextCount("log-2.txt"));
            Assert.Equal(1, stats.GetOpenTextCount("log-3.txt"));
        }
Exemplo n.º 2
0
        public void LogFileFinderIgnoredFilesAreOnlyReadOnce()
        {
            var fs = new ApplicationLogsTestFileSystem();

            FileSystemHelpers.Instance = fs;
            fs.AddLogFile("logging-errors.txt",
                          @"2014-01-09T00:18:30
System.ApplicationException: The trace listener AzureTableTraceListener is disabled. 
   at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureTableTraceListener.GetCloudTableClientFromEnvironment()
   at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureTableTraceListener.RefreshConfig()
   --- End of inner exception stack trace ---"
                          );

            var stats      = new ApplicationLogsReader.LogFileAccessStats();
            var env        = new ApplicationLogsTestEnvironment();
            var fileFinder = new ApplicationLogsReader.LogFileFinder(env, Mock.Of <ITracer>(), stats);
            var results    = fileFinder.FindLogFiles().ToList();

            Assert.Equal(0, results.Count);
            Assert.Equal(1, stats.GetOpenTextCount("logging-errors.txt"));

            results = fileFinder.FindLogFiles().ToList();

            Assert.Equal(0, results.Count);
            Assert.Equal(1, stats.GetOpenTextCount("logging-errors.txt"));
        }
Exemplo n.º 3
0
        public void LogFileFinderEmptyFilesAreReadEachTime()
        {
            var fs = new ApplicationLogsTestFileSystem();

            FileSystemHelpers.Instance = fs;
            fs.AddLogFile("log-1.txt", "");

            var stats      = new ApplicationLogsReader.LogFileAccessStats();
            var env        = new ApplicationLogsTestEnvironment();
            var fileFinder = new ApplicationLogsReader.LogFileFinder(env, Mock.Of <ITracer>(), stats);

            fileFinder.FindLogFiles();
            fileFinder.FindLogFiles();
            Assert.Equal(2, stats.GetOpenTextCount("log-1.txt"));
        }