Пример #1
0
        public void TestGetEntriesRawContent1()
        {
            var logFile = new InMemoryLogSource();

            logFile.AddEntry("foobar");
            var entries = logFile.GetEntries(new LogSourceSection(0, 1), new[] { Core.Columns.RawContent });

            entries.Count.Should().Be(1);
            entries.Columns.Should().Equal(new object[] { Core.Columns.RawContent }, "because we've only retrieved that column");
            entries[0].RawContent.Should().Be("foobar");
        }
Пример #2
0
        public void TestAddEntry6()
        {
            var logFile = new InMemoryLogSource(Core.Columns.LogLevel);

            var logEntry = new LogEntry
            {
                LogLevel = LevelFlags.Error
            };

            logFile.Add(logEntry);

            var buffer = new LogBufferArray(1, Core.Columns.LogLevel);

            logFile.GetEntries(new LogSourceSection(0, 1), buffer);
            buffer[0].LogLevel.Should().Be(LevelFlags.Error);
        }
Пример #3
0
        public void TestGetEntriesWithMinimumColumns()
        {
            var logFile = new InMemoryLogSource();

            logFile.AddEntry("", LevelFlags.Debug, new DateTime(2017, 12, 12, 00, 11, 0));
            logFile.AddEntry("", LevelFlags.Info);
            logFile.AddEntry("", LevelFlags.Error, new DateTime(2017, 12, 12, 00, 12, 0));

            var entries = logFile.GetEntries(new LogSourceSection(1, 2), Core.Columns.Minimum);

            entries.Count.Should().Be(2);
            entries.Columns.Should().Equal(Core.Columns.Minimum);
            entries[0].LogLevel.Should().Be(LevelFlags.Info);
            entries[0].Timestamp.Should().Be(null);
            entries[1].LogLevel.Should().Be(LevelFlags.Error);
            entries[1].Timestamp.Should().Be(new DateTime(2017, 12, 12, 00, 12, 0));
        }
Пример #4
0
        public void TestGetEntriesRandomAccess()
        {
            var logFile = new InMemoryLogSource();

            logFile.AddEntry("", LevelFlags.Debug, new DateTime(2017, 12, 12, 00, 11, 0));
            logFile.AddEntry("", LevelFlags.Info);
            logFile.AddEntry("", LevelFlags.Error, new DateTime(2017, 12, 12, 00, 12, 0));

            var entries = logFile.GetEntries(new LogSourceSection(1, 2), new IColumnDescriptor[] { Core.Columns.LogLevel, Core.Columns.Timestamp });

            entries.Count.Should().Be(2);
            entries.Columns.Should().Equal(new object[] { Core.Columns.LogLevel, Core.Columns.Timestamp });
            entries[0].LogLevel.Should().Be(LevelFlags.Info);
            entries[0].Timestamp.Should().Be(null);
            entries[1].LogLevel.Should().Be(LevelFlags.Error);
            entries[1].Timestamp.Should().Be(new DateTime(2017, 12, 12, 00, 12, 0));
        }
Пример #5
0
        public void TestGetEntriesWithElapsedTimeColumns()
        {
            var logFile = new InMemoryLogSource();

            logFile.AddEntry("", LevelFlags.Info);
            logFile.AddEntry("", LevelFlags.Debug, new DateTime(2017, 12, 12, 00, 11, 0));
            logFile.AddEntry("", LevelFlags.Info);
            logFile.AddEntry("", LevelFlags.Error, new DateTime(2017, 12, 12, 00, 12, 0));
            logFile.AddEntry("", LevelFlags.Error, new DateTime(2017, 12, 20, 17, 01, 0));

            var entries = logFile.GetEntries(new LogSourceSection(0, 5), new [] { Core.Columns.ElapsedTime });

            entries.Count.Should().Be(5);
            entries.Columns.Should().Equal(Core.Columns.ElapsedTime);
            entries[0].ElapsedTime.Should().Be(null);
            entries[1].ElapsedTime.Should().Be(TimeSpan.Zero);
            entries[2].ElapsedTime.Should().Be(null);
            entries[3].ElapsedTime.Should().Be(TimeSpan.FromMinutes(1));
            entries[4].ElapsedTime.Should().Be(TimeSpan.FromDays(8) + TimeSpan.FromHours(16) + TimeSpan.FromMinutes(50));
        }
Пример #6
0
        public void TestGetEntriesEmpty()
        {
            var logFile = new InMemoryLogSource();

            logFile.GetEntries(new LogSourceSection()).Should().BeEmpty("because the log file is empty");
        }