예제 #1
0
        public void NestedScopesWithRecords_KeepOnlyWithMinimalLogLevelStaringOnFirstMessageOccurrence()
        {
            var queue = new GrowingQueue("")
            {
                RecordFactory.Create(0, "no ", RecordType.Record, LogLevel.Information),

                RecordFactory.Create(1, "no ", RecordType.ScopeBeginIgnored),
                RecordFactory.Create(1, "no ", RecordType.Record, LogLevel.Information),

                RecordFactory.Create(2, "no ", RecordType.ScopeBeginIgnored),
                RecordFactory.Create(2, "yes", RecordType.Record, LogLevel.Error),
                RecordFactory.Create(2, "no ", RecordType.Record, LogLevel.Information),

                RecordFactory.Create(3, "no ", RecordType.ScopeBeginIgnored),
                RecordFactory.Create(3, "no ", RecordType.Record, LogLevel.Information),
                RecordFactory.Create(3, "yes", RecordType.Record, LogLevel.Error),
                RecordFactory.Create(3, "no ", RecordType.ScopeEndIgnored),

                RecordFactory.Create(2, "yes", RecordType.Record, LogLevel.Error),
                RecordFactory.Create(2, "no ", RecordType.ScopeEndIgnored),

                RecordFactory.Create(1, "no ", RecordType.Record, LogLevel.Information),
                RecordFactory.Create(1, "no ", RecordType.ScopeEndIgnored),

                RecordFactory.Create(0, "no ", RecordType.Record, LogLevel.Information)
            };

            var filter = new FlatQueueFilter(LogLevel.Error);
            var result = filter.Filter(queue);

            Assert.AreEqual(3, result.Count);
            Assert.IsTrue(result.All(l => l.Message == "yes"));
        }
예제 #2
0
        public void RecordsOnly_FilterWithLowerPriorities(LogLevel minimalLevel, int expected)
        {
            var queue = new GrowingQueue("")
            {
                RecordFactory.Create(0, RecordType.Record, LogLevel.Critical),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Error),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Warning),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Information),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Debug),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Trace)
            };

            var filter = new FlatQueueFilter(minimalLevel);
            var result = filter.Filter(queue);

            Assert.AreEqual(expected, result.Count);
        }