public void TheLogFileIsNotRequiredToIncludeADirectory()
 {
     var roller = new TemplatedPathRoller("log-{Date}");
     var now = new DateTime(2013, 7, 14, 3, 24, 9, 980);
     var path = roller.GetLogFilePath(now, LogEventLevel.Information, 0);
     AssertEqualAbsolute("log-20130714", path);
 }
 public void ANonZeroIncrementIsIncludedAndPadded()
 {
     var roller = new TemplatedPathRoller("Logs\\log.{Date}.txt");
     var now = new DateTime(2013, 7, 14, 3, 24, 9, 980);
     var path = roller.GetLogFilePath(now, LogEventLevel.Information, 12);
     AssertEqualAbsolute("Logs\\log.20130714_0012.txt", path);
 }
 public void IfNoTokenIsSpecifiedDashFollowedByTheDateIsImplied()
 {
     var roller = new TemplatedPathRoller("Logs\\log.txt");
     var now = new DateTime(2013, 7, 14, 3, 24, 9, 980);
     var path = roller.GetLogFilePath(now, LogEventLevel.Information, 0);
     AssertEqualAbsolute("Logs\\log-20130714.txt", path);
 }
 public void TheLogFileIncludesDateToken(string pattern, string expectedResult)
 {
     var roller = new TemplatedPathRoller(pattern);
     var now = new DateTime(2013, 7, 14, 3, 24, 9, 980);
     var path = roller.GetLogFilePath(now, LogEventLevel.Information, 0);
     AssertEqualAbsolute(expectedResult, path);
 }
コード例 #5
0
        public void MatchingParsesSubstitutions(string template, string newer, string older)
        {
            var roller  = new TemplatedPathRoller(template);
            var matched = roller.SelectMatches(new[] { older, newer }).OrderByDescending(m => m.DateTime).Select(m => m.Filename).ToArray();

            Assert.Equal(new[] { newer, older }, matched);
        }
        public void ANonZeroIncrementIsIncludedAndPadded()
        {
            var roller = new TemplatedPathRoller("Logs\\log.{Date}.txt");
            var now    = new DateTime(2013, 7, 14, 3, 24, 9, 980);
            var path   = roller.GetLogFilePath(now, 12);

            AssertEqualAbsolute("Logs\\log.20130714_0012.txt", path);
        }
        public void IfNoTokenIsSpecifiedDashFollowedByTheDateIsImplied()
        {
            var roller = new TemplatedPathRoller("Logs\\log.txt");
            var now    = new DateTime(2013, 7, 14, 3, 24, 9, 980);
            var path   = roller.GetLogFilePath(now, 0);

            AssertEqualAbsolute("Logs\\log-20130714.txt", path);
        }
        public void TheLogFileIsNotRequiredToIncludeADirectory()
        {
            var roller = new TemplatedPathRoller("log-{Date}");
            var now    = new DateTime(2013, 7, 14, 3, 24, 9, 980);
            var path   = roller.GetLogFilePath(now, 0);

            AssertEqualAbsolute("log-20130714", path);
        }
        public void TheLogFileIncludesDateToken()
        {
            var roller = new TemplatedPathRoller("Logs\\log.{Date}.txt");
            var now    = new DateTime(2013, 7, 14, 3, 24, 9, 980);
            var path   = roller.GetLogFilePath(now, 0);

            AssertEqualAbsolute("Logs\\log.20130714.txt", path);
        }
コード例 #10
0
        public void OrderingMatchesFiles()
        {
            var          roller  = new TemplatedPathRoller("log-{Date}.txt");
            const string example = "log-20131210.txt";
            var          matched = roller.OrderMatchingByAge(new[] { example });

            Assert.AreEqual(1, matched.Count());
        }
コード例 #11
0
        public void OrderingPresentsNewerFilesFirst()
        {
            var          roller  = new TemplatedPathRoller("log-{Date}.txt");
            const string newer   = "log-20150101.txt";
            const string older   = "log-20141231.txt";
            var          matched = roller.OrderMatchingByAge(new[] { older, newer });

            CollectionAssert.AreEqual(new[] { newer, older }, matched);
        }
コード例 #12
0
        public void MatchingExcludesSimilarButNonmatchingFiles()
        {
            var          roller   = new TemplatedPathRoller("log-{Date}.txt");
            const string similar1 = "log-0.txt";
            const string similar2 = "log-helloyou.txt";
            var          matched  = roller.SelectMatches(new[] { similar1, similar2 });

            Assert.Equal(0, matched.Count());
        }
コード例 #13
0
        public void MatchingSelectsFiles(string template, string zeroth, string thirtyFirst)
        {
            var roller  = new TemplatedPathRoller(template);
            var matched = roller.SelectMatches(new[] { zeroth, thirtyFirst }).ToArray();

            Assert.Equal(2, matched.Count());
            Assert.Equal(0, matched[0].SequenceNumber);
            Assert.Equal(31, matched[1].SequenceNumber);
        }
コード例 #14
0
        public void TheLogFileIsNotRequiredToIncludeAnExtension()
        {
            var    roller = new TemplatedPathRoller("Logs\\log-{Date}");
            var    now    = new DateTime(2013, 7, 14, 3, 24, 9, 980);
            string path;

            roller.GetLogFilePath(now, 0, out path);
            AssertEqualAbsolute("Logs\\log-20130714", path);
        }
        public void MatchingParsesDates()
        {
            var          roller  = new TemplatedPathRoller("log-{Date}.txt");
            const string newer   = "log-20150101.txt";
            const string older   = "log-20141231.txt";
            var          matched = roller.SelectMatches(new[] { newer, older }).OrderBy(m => m.Date).Select(m => m.Filename).ToArray();

            Assert.AreEqual(new[] { newer, older }, matched);
        }
コード例 #16
0
        public void TheLogFileIsNotRequiredToIncludeADirectory()
        {
            var      roller = new TemplatedPathRoller("log-{Date}");
            var      now    = new DateTime(2013, 7, 14, 3, 24, 9, 980);
            string   path;
            DateTime nextCheckpoint;

            roller.GetLogFilePath(now, out path, out nextCheckpoint);
            Assert.AreEqual("log-20130714", path);
        }
コード例 #17
0
        public void IfNoTokenIsSpecifiedDashFollowedByTheDateIsImplied()
        {
            var      roller = new TemplatedPathRoller("Logs\\log.txt");
            var      now    = new DateTime(2013, 7, 14, 3, 24, 9, 980);
            string   path;
            DateTime nextCheckpoint;

            roller.GetLogFilePath(now, out path, out nextCheckpoint);
            Assert.AreEqual("Logs\\log-20130714.txt", path);
        }
コード例 #18
0
        public void TheLogFileIncludesDateTokenAndSetsCheckpointToNextDay()
        {
            var      roller = new TemplatedPathRoller("Logs\\log.{Date}.txt");
            var      now    = new DateTime(2013, 7, 14, 3, 24, 9, 980);
            string   path;
            DateTime nextCheckpoint;

            roller.GetLogFilePath(now, out path, out nextCheckpoint);
            Assert.AreEqual("Logs\\log.20130714.txt", path);
            Assert.AreEqual(new DateTime(2013, 7, 15), nextCheckpoint);
        }
        public void MatchingSelectsFiles()
        {
            var          roller   = new TemplatedPathRoller("log-{Date}.txt");
            const string example1 = "log-20131210.txt";
            const string example2 = "log-20131210_031.txt";
            var          matched  = roller.SelectMatches(new[] { example1, example2 }).ToArray();

            Assert.AreEqual(2, matched.Count());
            Assert.AreEqual(0, matched[0].SequenceNumber);
            Assert.AreEqual(31, matched[1].SequenceNumber);
        }
        public void MatchingSelectsFilesIncludeLevel()
        {
            var roller = new TemplatedPathRoller("log-{Date}-{Level}.txt");
            const string example1 = "log-20131210-information.txt";
            const string example2 = "log-20131210-debug_031.txt";
            const string example3 = "log-20131210-021.txt";
            var matched = roller.SelectMatches(new[] { example1, example2, example3 }).ToArray();
            Assert.AreEqual(2, matched.Count());
            Assert.AreEqual(0, matched[0].SequenceNumber);
            Assert.AreEqual(31, matched[1].SequenceNumber);

            Assert.AreEqual(LogEventLevel.Information, matched[0].Level);
            Assert.AreEqual(LogEventLevel.Debug, matched[1].Level);
        }
コード例 #21
0
        public void TheRollerReturnsTheLogFileDirectory()
        {
            var roller = new TemplatedPathRoller("Logs\\log.{Date}.txt");

            AssertEqualAbsolute("Logs", roller.LogFileDirectory);
        }
 public void MatchingParsesDates()
 {
     var roller = new TemplatedPathRoller("log-{Date}.txt");
     const string newer = "log-20150101.txt";
     const string older = "log-20141231.txt";
     var matched = roller.SelectMatches(new[] { newer, older }).OrderBy(m => m.Date).Select(m => m.Filename).ToArray();
     Assert.AreEqual(new[] { newer, older }, matched);
 }
コード例 #23
0
        public void TheDirectorSearchPatternUsesWildcardInPlaceOfDate(string template)
        {
            var roller = new TemplatedPathRoller(template);

            Assert.Equal("log-*.txt", roller.DirectorySearchPattern);
        }
        public void TheDirectorSearchPatternUsesWildcardInPlaceOfDate()
        {
            var roller = new TemplatedPathRoller("Logs\\log-{Date}.txt");

            Assert.AreEqual("log-*.txt", roller.DirectorySearchPattern);
        }
 public void TheRollerReturnsTheLogFileDirectory()
 {
     var roller = new TemplatedPathRoller("Logs\\log.{Date}.txt");
     AssertEqualAbsolute("Logs", roller.LogFileDirectory);
 }
 public void TheDirectorSearchPatternUsesWildcardInPlaceOfDate()
 {
     var roller = new TemplatedPathRoller("Logs\\log-{Date}.txt");
     Assert.AreEqual("log-*.txt", roller.DirectorySearchPattern);
 }
 public void MatchingSelectsFiles()
 {
     var roller = new TemplatedPathRoller("log-{Date}.txt");
     const string example1 = "log-20131210.txt";
     const string example2 = "log-20131210-debug_031.txt";
     const string example3 = "log-20131210_031.txt";
     var matched = roller.SelectMatches(new[] { example1, example2, example3 }).ToArray();
     Assert.AreEqual(2, matched.Count());
     Assert.AreEqual(0, matched[0].SequenceNumber);
     Assert.AreEqual(31, matched[1].SequenceNumber);
 }
 public void MatchingExcludesSimilarButNonmatchingFiles()
 {
     var roller = new TemplatedPathRoller("log-{Date}.txt");
     const string similar1 = "log-0.txt";
     const string similar2 = "log-helloyou.txt";
     var matched = roller.SelectMatches(new[] { similar1, similar2 });
     Assert.AreEqual(0, matched.Count());
 }