示例#1
0
        public void TestMultipleLinesOneEntry()
        {
            var source = new InMemoryLogFile();

            source.AddEntry("2017-12-03 11:59:30 Hello, ", LevelFlags.Other, new DateTime(2017, 12, 3, 11, 59, 30));
            source.AddEntry("World!", LevelFlags.Other);
            var logFile = new MultiLineLogFile(_taskScheduler, source, TimeSpan.Zero);

            _taskScheduler.RunOnce();

            logFile.Count.Should().Be(2);

            var entries = logFile.GetEntries(new[] { new LogLineIndex(0), new LogLineIndex(1) },
                                             new ILogFileColumn[]
            {
                LogFileColumns.LineNumber, LogFileColumns.LogEntryIndex, LogFileColumns.Timestamp,
                LogFileColumns.RawContent
            });
            var line = entries[0];

            line.GetValue(LogFileColumns.LineNumber).Should().Be(1);
            line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(0);
            line.RawContent.Should().Be("2017-12-03 11:59:30 Hello, ");

            line = entries[1];
            line.GetValue(LogFileColumns.LineNumber).Should().Be(2);
            line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(0);
            line.RawContent.Should().Be("World!");
        }
示例#2
0
        public void TestMultilineNoLevel2()
        {
            using (var source = new TextLogFile(_scheduler, TextLogFileAcceptanceTest.MultilineNoLogLevel1, new CustomTimestampParser()))
                using (var multi = new MultiLineLogFile(_scheduler, source, TimeSpan.Zero))
                {
                    multi.Property(x => x.Count).ShouldAfter(TimeSpan.FromMinutes(5)).Be(6);
                    var entries = multi.GetEntries(new List <LogLineIndex>
                    {
                        new LogLineIndex(0),
                        new LogLineIndex(1),
                        new LogLineIndex(2),
                        new LogLineIndex(3),
                        new LogLineIndex(4),
                        new LogLineIndex(5)
                    },
                                                   LogFileColumns.Timestamp,
                                                   LogFileColumns.LogEntryIndex,
                                                   LogFileColumns.LineNumber,
                                                   LogFileColumns.RawContent);

                    var line = entries[0];
                    line.GetValue(LogFileColumns.Timestamp).Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 177));
                    line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(new LogEntryIndex(0));
                    line.GetValue(LogFileColumns.LineNumber).Should().Be(1);
                    line.GetValue(LogFileColumns.RawContent).Should().Be("2019-03-18 14:09:54:177 1 00:00:00:0000000 Information Initialize Globals");

                    line = entries[1];
                    line.GetValue(LogFileColumns.Timestamp).Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 177));
                    line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(new LogEntryIndex(0));
                    line.GetValue(LogFileColumns.LineNumber).Should().Be(2);
                    line.GetValue(LogFileColumns.RawContent).Should().Be("Started BTPVM3372 05:30:00 6060");

                    line = entries[2];
                    line.GetValue(LogFileColumns.Timestamp).Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 313));
                    line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(new LogEntryIndex(1));
                    line.GetValue(LogFileColumns.LineNumber).Should().Be(3);
                    line.GetValue(LogFileColumns.RawContent).Should().Be("2019-03-18 14:09:54:313 1 00:00:00:0000000 Information   Loading");

                    line = entries[3];
                    line.GetValue(LogFileColumns.Timestamp).Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 313));
                    line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(new LogEntryIndex(1));
                    line.GetValue(LogFileColumns.LineNumber).Should().Be(4);
                    line.GetValue(LogFileColumns.RawContent).Should().Be("preferences Started BTPVM3372 05:30:00 6060");

                    line = entries[4];
                    line.GetValue(LogFileColumns.Timestamp).Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 551));
                    line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(new LogEntryIndex(2));
                    line.GetValue(LogFileColumns.LineNumber).Should().Be(5);
                    line.GetValue(LogFileColumns.RawContent).Should().Be("2019-03-18 14:09:54:551 1 00:00:00:0000000 Information    RMClientURL:");

                    line = entries[5];
                    line.GetValue(LogFileColumns.Timestamp).Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 551));
                    line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(new LogEntryIndex(2));
                    line.GetValue(LogFileColumns.LineNumber).Should().Be(6);
                    line.GetValue(LogFileColumns.RawContent).Should().Be("BTPVM3372 05:30:00 6060");
                }
        }
示例#3
0
        public void TestGetEntriesByIndices()
        {
            var logFile          = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero);
            var indices          = new LogLineIndex[] { 0, 2, 5 };
            var buffer           = new LogEntryBuffer(3, LogFileColumns.DeltaTime, LogFileColumns.Timestamp);
            var destinationIndex = 2;

            logFile.GetEntries(indices, buffer, destinationIndex);

            _source.Verify(x => x.GetEntries(It.Is <IReadOnlyList <LogLineIndex> >(y => y == indices),
                                             It.Is <ILogEntries>(y => y == buffer),
                                             It.Is <int>(y => y == destinationIndex)),
                           Times.Once);
        }
示例#4
0
        public void TestGetEntriesBySection()
        {
            var logFile          = new MultiLineLogFile(_taskScheduler, _source.Object, TimeSpan.Zero);
            var section          = new LogFileSection(42, 5);
            var buffer           = new LogEntryBuffer(3, LogFileColumns.DeltaTime, LogFileColumns.Timestamp);
            var destinationIndex = 2;

            logFile.GetEntries(section, buffer, destinationIndex);

            _source.Verify(x => x.GetEntries(It.Is <LogFileSection>(y => y == section),
                                             It.Is <ILogEntries>(y => y == buffer),
                                             It.Is <int>(y => y == destinationIndex)),
                           Times.Once);
        }
示例#5
0
        public void TestFuck()
        {
            var source = new InMemoryLogFile();

            source.AddEntry("2019-07-08 16:19:13.546 [TID = 01428] [CSomeClass::FooBar()] [Session 1337] [FW]", LevelFlags.Other, new DateTime(2019, 7, 8, 16, 19, 13, 546));
            source.AddEntry("2019-07-08 16:19:13.546 [TID = 01428] [CSomeClass::FooBar()] [Session 1337] [FW] [IND_ERROR] [The test case had to be terminated.] [The stack has indicated an UNKNOWN error.SAP Name = 'EM', AppName = 'lte-l1c-phy.elf', StatusInfo = '<missing>']", LevelFlags.Other, new DateTime(2019, 7, 8, 16, 19, 13, 546));
            source.AddEntry("2019-07-08 16:19:13.546 [TID = 01428] [CSomeOtherClass::Ooopsie()][Whoops] [to] [eTC_STOP_EVENT_SUSPEND_IND]", LevelFlags.Other, new DateTime(2019, 7, 8, 16, 19, 13, 546));

            var logFile = new MultiLineLogFile(_taskScheduler, source, TimeSpan.Zero);

            _taskScheduler.RunOnce();
            logFile.Count.Should().Be(3);
            var entries = logFile.GetEntries(new LogFileSection(0, 3), LogFileColumns.LogEntryIndex);

            entries[0].LogEntryIndex.Should().Be(new LogEntryIndex(0));
            entries[1].LogEntryIndex.Should().Be(new LogEntryIndex(1));
            entries[2].LogEntryIndex.Should().Be(new LogEntryIndex(2));
        }