예제 #1
0
        public void Get(IDateTimeProvider timeProvider, ILogger <DataFilePathProvider> logger, IFileSystem fileSystem)
        {
            var settings = Substitute.ForPartsOf <AutoSettings>();

            fileSystem.GetTempDirectoryPath().Returns(Path.GetTempPath());
            var    sut           = new DataFilePathProvider(settings, timeProvider, logger, fileSystem);
            string resultDir     = TestContext.CurrentContext.TestDirectory;
            var    expectedFiles = new[] {
                "collect_deadlock_data_123.xel",
                "collect_long_locks_data_123dfds.xel",
                "ts_sqlprofiler_05_sec_asdv.xel"
            };
            string xEventsDir = CreateTestFiles(timeProvider, expectedFiles);
            var    now        = DateTime.UtcNow.AddHours(1);

            timeProvider.UtcNow.Returns(now);
            settings.EventsDataDirectoryTemplate.Returns(xEventsDir);
            List <string> files = new List <string>();

            foreach (string dir in sut.GetDailyExtEventsDirs())
            {
                resultDir = dir;
                files.AddRange(Directory.EnumerateFiles(dir).Select(Path.GetFileName));
            }
            files.Should().BeEquivalentTo(expectedFiles);
            DirectoryAssert.DoesNotExist(resultDir);
        }
예제 #2
0
        private static DataFilePathProvider SetupProvider(ISettings settings)
        {
            settings.DailyLogsDirectoryTemplate.Returns("yyyy_MM_dd");
            string dirPrefix = TestContext.CurrentContext.TestDirectory;

            settings.DirectoriesWithJsonLog.Returns(
                $"{dirPrefix}\\TestDir\\LogDir3;{dirPrefix}\\TestDir\\LogDir2;{dirPrefix}\\TestDir\\LogDir1");
            var sut = new DataFilePathProvider(settings, new StaticDateTimeProvider(new DateTime(2017, 07, 13)), Substitute.For <ILogger <DataFilePathProvider> >(), Substitute.For <IFileSystem>());

            return(sut);
        }
예제 #3
0
        public void GetPerfomanceLogs(ISettings settings)
        {
            DataFilePathProvider sut = SetupProvider(settings);

            settings.PerfomanceLogFileName.Returns("LoggingDataReader.json.0.json");
            var counter = 0;

            foreach (string executorLog in sut.GetPerfomanceLogs())
            {
                AssertValidFile(executorLog);
                counter++;
            }
            counter.Should().Be(4);
        }