Exemple #1
0
        public void TestAppendTwoSourcesWrongOrderSeparateChangesPartialInvalidation()
        {
            var source1 = new InMemoryLogFile();

            source1.AddEntry("A", LevelFlags.Other, new DateTime(2019, 5, 28, 00, 34, 0));
            source1.AddEntry("C", LevelFlags.Other, new DateTime(2019, 5, 28, 00, 36, 0));
            var source2 = new InMemoryLogFile();

            source2.AddEntry("B", LevelFlags.Other, new DateTime(2019, 5, 28, 00, 35, 0));
            source2.AddEntry("D", LevelFlags.Other, new DateTime(2019, 5, 28, 00, 37, 0));

            var index   = new MergedLogFileIndex(source1, source2);
            var changes = index.Process(new MergedLogFilePendingModification(source1, new LogFileSection(0, 2)));

            changes.Should().Equal(new object[]
            {
                new LogFileSection(0, 2)
            });

            changes = index.Process(new MergedLogFilePendingModification(source2, new LogFileSection(0, 2)));
            changes.Should().Equal(new object[]
            {
                LogFileSection.Invalidate(1, 1),
                new LogFileSection(1, 3)
            });
        }
Exemple #2
0
        public void TestAddEntry3()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hello, World!", LevelFlags.Info);
            logFile.AddEntry("Hi", LevelFlags.Info);
            logFile.MaxCharactersPerLine.Should().Be(13);
        }
Exemple #3
0
        public void TestClear2()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hello,", LevelFlags.Info);
            logFile.AddEntry(" World!", LevelFlags.Warning);
            logFile.Clear();
            logFile.Count.Should().Be(0);
        }
Exemple #4
0
        public void TestAppendTwoSourcesInterlocked()
        {
            var source1 = new InMemoryLogFile();

            source1.AddEntry("A", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 0));
            source1.AddEntry("B", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 2));
            source1.AddEntry("C", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 4));
            source1.AddEntry("D", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 6));
            source1.AddEntry("E", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 8));
            var source2 = new InMemoryLogFile();

            source2.AddEntry("1", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 1));
            source2.AddEntry("2", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 3));
            source2.AddEntry("3", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 5));
            source2.AddEntry("4", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 7));
            source2.AddEntry("5", LevelFlags.None, new DateTime(2019, 5, 29, 00, 11, 9));

            var index = new MergedLogFileIndex(source1, source2);

            index.Process(new MergedLogFilePendingModification(source1, new LogFileSection(0, 5)));
            index.Process(new MergedLogFilePendingModification(source2, new LogFileSection(0, 5)));

            var indices = index.Get(new LogFileSection(0, 10));

            indices[0].LogFileIndex.Should().Be(0);
            indices[0].SourceLineIndex.Should().Be(0);

            indices[1].LogFileIndex.Should().Be(1);
            indices[1].SourceLineIndex.Should().Be(0);

            indices[2].LogFileIndex.Should().Be(0);
            indices[2].SourceLineIndex.Should().Be(1);

            indices[3].LogFileIndex.Should().Be(1);
            indices[3].SourceLineIndex.Should().Be(1);

            indices[4].LogFileIndex.Should().Be(0);
            indices[4].SourceLineIndex.Should().Be(2);

            indices[5].LogFileIndex.Should().Be(1);
            indices[5].SourceLineIndex.Should().Be(2);

            indices[6].LogFileIndex.Should().Be(0);
            indices[6].SourceLineIndex.Should().Be(3);

            indices[7].LogFileIndex.Should().Be(1);
            indices[7].SourceLineIndex.Should().Be(3);

            indices[8].LogFileIndex.Should().Be(0);
            indices[8].SourceLineIndex.Should().Be(4);

            indices[9].LogFileIndex.Should().Be(1);
            indices[9].SourceLineIndex.Should().Be(4);
        }
Exemple #5
0
        public void TestAddEntry2()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hello,", LevelFlags.Info, new DateTime(2017, 4, 29, 14, 56, 0));
            logFile.AddEntry(" World!", LevelFlags.Warning, new DateTime(2017, 4, 29, 14, 56, 2));
            logFile.Count.Should().Be(2);
            logFile.GetLine(0).Should().Be(new LogLine(0, 0, "Hello,", LevelFlags.Info, new DateTime(2017, 4, 29, 14, 56, 0)));
            logFile.GetLine(1).Should().Be(new LogLine(1, 1, " World!", LevelFlags.Warning, new DateTime(2017, 4, 29, 14, 56, 2)));
            logFile.GetValue(LogFileProperties.StartTimestamp).Should().Be(new DateTime(2017, 4, 29, 14, 56, 0));
        }
        public void TestAnalyseOneEntry()
        {
            _logFile.AddEntry("foobar", LevelFlags.All);
            var analyser = new LogEntryCountAnalyser(_scheduler,
                                                     _logFile,
                                                     TimeSpan.Zero,
                                                     new LogEntryCountAnalyserConfiguration());

            _scheduler.RunOnce();
            analyser.Result.Should().NotBeNull();
            analyser.Result.Should().BeOfType <LogEntryCountResult>();
            ((LogEntryCountResult)analyser.Result).Count.Should().Be(1);
        }
Exemple #7
0
        public void TestTwoLines()
        {
            var stream  = new MemoryStream();
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hello,", LevelFlags.Other);
            logFile.AddEntry("World!", LevelFlags.Other);
            var exporter = new LogFileToStreamExporter(logFile, stream);

            new Action(() => exporter.Export()).Should().NotThrow();

            GetString(stream).Should().Be("Hello,\r\nWorld!");
        }
Exemple #8
0
        public void TestOneSourceManySameTimestamps()
        {
            var source = new InMemoryLogFile();

            source.AddEntry("A", LevelFlags.None, new DateTime(2017, 9, 20, 15, 09, 02, 053));
            source.AddEntry("B", LevelFlags.None, new DateTime(2017, 9, 20, 15, 09, 02, 100));
            source.AddEntry("C", LevelFlags.None, new DateTime(2017, 9, 20, 15, 09, 02, 100));
            source.AddEntry("D", LevelFlags.None, new DateTime(2017, 9, 20, 15, 09, 02, 100));
            source.AddEntry("E", LevelFlags.None, new DateTime(2017, 9, 20, 15, 09, 02, 115));
            source.AddEntry("F", LevelFlags.None, new DateTime(2017, 9, 20, 15, 09, 02, 115));
            source.AddEntry("G", LevelFlags.None, new DateTime(2017, 9, 20, 15, 09, 02, 115));
            source.AddEntry("H", LevelFlags.None, new DateTime(2017, 9, 20, 15, 09, 02, 115));

            var index = new MergedLogFileIndex(source);

            index.Process(new MergedLogFilePendingModification(source, new LogFileSection(0, 8)));

            var indices = index.Get(new LogFileSection(0, 8));

            indices[0].SourceLineIndex.Should().Be(0);
            indices[1].SourceLineIndex.Should().Be(1);
            indices[2].SourceLineIndex.Should().Be(2);
            indices[3].SourceLineIndex.Should().Be(3);
            indices[4].SourceLineIndex.Should().Be(4);
            indices[5].SourceLineIndex.Should().Be(5);
            indices[6].SourceLineIndex.Should().Be(6);
            indices[7].SourceLineIndex.Should().Be(7);
        }
Exemple #9
0
        public void TestGetEntriesRawContent2()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("foo");
            logFile.AddEntry("bar");
            logFile.AddEntry("some lazy fox");
            var entries = logFile.GetEntries(new LogFileSection(1, 2), LogFileColumns.RawContent);

            entries.Count.Should().Be(2);
            entries.Columns.Should().Equal(new object[] { LogFileColumns.RawContent }, "because we've only retrieved that column");
            entries[0].RawContent.Should().Be("bar");
            entries[1].RawContent.Should().Be("some lazy fox");
        }
Exemple #10
0
        public void TestGetLogLineIndexOfOriginalLineIndex2()
        {
            var logFile = new InMemoryLogFile();

            logFile.GetLogLineIndexOfOriginalLineIndex(0).Should().Be(LogLineIndex.Invalid);
            logFile.AddEntry("", LevelFlags.All);
            logFile.GetLogLineIndexOfOriginalLineIndex(0).Should().Be(new LogLineIndex(0));
            logFile.GetLogLineIndexOfOriginalLineIndex(1).Should().Be(LogLineIndex.Invalid);
            logFile.AddEntry("", LevelFlags.All);
            logFile.GetLogLineIndexOfOriginalLineIndex(0).Should().Be(new LogLineIndex(0));
            logFile.GetLogLineIndexOfOriginalLineIndex(1).Should().Be(new LogLineIndex(1));
            logFile.Clear();
            logFile.GetLogLineIndexOfOriginalLineIndex(0).Should().Be(LogLineIndex.Invalid);
            logFile.GetLogLineIndexOfOriginalLineIndex(1).Should().Be(LogLineIndex.Invalid);
        }
Exemple #11
0
        public void TestExportTwoLines()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hello,", LevelFlags.Other);
            logFile.AddEntry("World!", LevelFlags.Other);
            var exporter = new LogFileToFileExporter(logFile, _directory, "foo");

            exporter.FullExportFilename.Should().BeNull("because the full filename must be determined from inside Export, NOT beforehand");
            new Action(() => exporter.Export()).Should().NotThrow();
            exporter.FullExportFilename.Should().NotBeNull();
            exporter.FullExportFilename.Should().StartWith(_directory);

            GetString(exporter.FullExportFilename).Should().Be("Hello,\r\nWorld!");
        }
Exemple #12
0
        public void TestAppendTwoSourcesWrongOrder()
        {
            var source1 = new InMemoryLogFile();

            source1.AddEntry("B", LevelFlags.None, new DateTime(2019, 5, 27, 23, 10, 0));
            var source2 = new InMemoryLogFile();

            source2.AddEntry("A", LevelFlags.None, new DateTime(2019, 5, 27, 23, 09, 0));

            var index   = new MergedLogFileIndex(source1, source2);
            var changes = index.Process(new MergedLogFilePendingModification(source1, new LogFileSection(0, 1)),
                                        new MergedLogFilePendingModification(source2, new LogFileSection(0, 1)));

            changes.Should().Equal(new object[]
            {
                new LogFileSection(0, 2)
            });

            var indices = index.Get(new LogFileSection(0, 2));

            indices.Count.Should().Be(2);
            indices[0].LogFileIndex.Should().Be(1);
            indices[0].SourceLineIndex.Should().Be(0);
            indices[0].OriginalLogEntryIndex.Should().Be(0);
            indices[0].MergedLogEntryIndex.Should().Be(0);
            indices[0].Timestamp.Should().Be(new DateTime(2019, 5, 27, 23, 9, 0));

            indices[1].LogFileIndex.Should().Be(0);
            indices[1].SourceLineIndex.Should().Be(0);
            indices[1].OriginalLogEntryIndex.Should().Be(0);
            indices[1].MergedLogEntryIndex.Should().Be(1);
            indices[1].Timestamp.Should().Be(new DateTime(2019, 5, 27, 23, 10, 0));
        }
Exemple #13
0
        public void TestOneSourceAppendReset()
        {
            var source1 = new InMemoryLogFile();

            source1.AddEntry("A", LevelFlags.None, new DateTime(2019, 5, 28, 00, 34, 0));

            var index   = new MergedLogFileIndex(source1);
            var changes = index.Process(new MergedLogFilePendingModification(source1, new LogFileSection(0, 1)));

            changes.Should().Equal(new object[]
            {
                new LogFileSection(0, 1)
            });

            changes = index.Process(new MergedLogFilePendingModification(source1, LogFileSection.Reset));
            changes.Should().Equal(new object[]
            {
                LogFileSection.Reset
            });
            index.Count.Should().Be(0);
            index.Get(new LogFileSection(0, 1)).Should().Equal(new object[]
            {
                MergedLogLineIndex.Invalid
            });
        }
Exemple #14
0
        public void TestMerge6()
        {
            var source0 = new InMemoryLogFile();
            var source1 = new InMemoryLogFile();

            var merged  = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source0, source1);
            var data    = Listen(merged);
            var changes = ListenToChanges(merged, 1);

            merged.OnLogFileModified(source0, LogFileSection.Reset);
            merged.OnLogFileModified(source0, LogFileSection.Reset);
            merged.OnLogFileModified(source0, LogFileSection.Reset);
            merged.OnLogFileModified(source0, LogFileSection.Reset);
            merged.OnLogFileModified(source0, LogFileSection.Reset);
            merged.OnLogFileModified(source0, LogFileSection.Reset);
            merged.OnLogFileModified(source1, LogFileSection.Reset);

            DateTime timestamp = DateTime.Now;

            source1.AddEntry("Hello World", LevelFlags.Info, timestamp);

            _taskScheduler.RunOnce();
            merged.EndOfSourceReached.Should().BeTrue();

            data.Should().Equal(new object[]
            {
                new LogLine(0, 0, new LogLineSourceId(1), "Hello World", LevelFlags.Info, timestamp)
            });

            int count = changes.Count;

            changes.ElementAt(count - 2).Should().Equal(LogFileSection.Reset);
            changes.ElementAt(count - 1).Should().Equal(new LogFileSection(0, 1));
        }
Exemple #15
0
        public void TestMerge5()
        {
            var source0 = new InMemoryLogFile();
            var source1 = new InMemoryLogFile();

            var merged = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source0, source1);
            var data   = Listen(merged);

            var later   = new DateTime(2016, 2, 16);
            var earlier = new DateTime(2016, 2, 15);

            source0.AddEntry("a", LevelFlags.Warning, later);

            _taskScheduler.RunOnce();
            merged.EndOfSourceReached.Should().BeTrue();

            source1.AddEntry("c", LevelFlags.Error, earlier);

            _taskScheduler.RunOnce();
            merged.EndOfSourceReached.Should().BeTrue();
            merged.Count.Should().Be(2);
            data.Should().Equal(new object[]
            {
                new LogLine(0, 0, new LogLineSourceId(1), "c", LevelFlags.Error, earlier),
                new LogLine(1, 1, new LogLineSourceId(0), "a", LevelFlags.Warning, later)
            });
        }
 private void AddLines(int count)
 {
     for (int i = 0; i < count; ++i)
     {
         _logFile.AddEntry("", LevelFlags.Fatal);
     }
 }
Exemple #17
0
        public void TestMerge3()
        {
            var source0 = new InMemoryLogFile();
            var source1 = new InMemoryLogFile();
            var merged  = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source0, source1);
            var data    = Listen(merged);

            DateTime timestamp = DateTime.Now;

            source0.AddEntry("a", LevelFlags.Info, timestamp);

            _taskScheduler.RunOnce();
            merged.EndOfSourceReached.Should().BeTrue();

            source1.AddEntry("b", LevelFlags.Debug, timestamp);

            _taskScheduler.RunOnce();
            merged.EndOfSourceReached.Should().BeTrue();
            merged.Count.Should().Be(2);
            data.Should().Equal(new object[]
            {
                new LogLine(0, 0, 0, new LogLineSourceId(0), "a", LevelFlags.Info, timestamp),
                new LogLine(1, 1, 1, new LogLineSourceId(1), "b", LevelFlags.Debug, timestamp)
            });
        }
Exemple #18
0
        public void TestGetEntriesWithMinimumColumns()
        {
            var logFile = new InMemoryLogFile();

            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 LogFileSection(1, 2), LogFileColumns.Minimum);

            entries.Count.Should().Be(2);
            entries.Columns.Should().Equal(LogFileColumns.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));
        }
Exemple #19
0
        public void TestGetDeltaTimesOneSource2()
        {
            var source  = new InMemoryLogFile();
            var logFile = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source);

            source.AddEntry("", LevelFlags.Other, new DateTime(2017, 12, 14, 23, 27, 0));
            source.AddEntry("", LevelFlags.Other, new DateTime(2017, 12, 14, 23, 28, 23));
            _taskScheduler.Run(2);

            var deltaTimes = logFile.GetColumn(new LogLineIndex[] { 1, 0 }, LogFileColumns.DeltaTime);

            deltaTimes.Should().Equal(new object[]
            {
                TimeSpan.FromSeconds(83),
                null
            });
        }
Exemple #20
0
        public void TestMerge2()
        {
            var source1 = new InMemoryLogFile();
            var source2 = new InMemoryLogFile();
            var merged  = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source1, source2);
            IEnumerable <LogLine> data = Listen(merged);

            source1.AddEntry("a", LevelFlags.Info, new DateTime(2019, 5, 28, 21, 59, 0));
            source1.AddEntry("b", LevelFlags.Debug, new DateTime(2019, 5, 28, 22, 0, 0));

            _taskScheduler.RunOnce();
            merged.Count.Should().Be(2);
            data.Should().Equal(new object[]
            {
                new LogLine(0, 0, "a", LevelFlags.Info, new DateTime(2019, 5, 28, 21, 59, 0)),
                new LogLine(1, 1, "b", LevelFlags.Debug, new DateTime(2019, 5, 28, 22, 0, 0)),
            });
        }
Exemple #21
0
        public void TestAddEntry1()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hello, World!", LevelFlags.Info);
            logFile.Count.Should().Be(1);
            logFile.MaxCharactersPerLine.Should().Be(13);
            logFile.GetValue(LogFileProperties.StartTimestamp).Should().BeNull();
        }
Exemple #22
0
        public void TestGetDeltaTime2()
        {
            var filter = new NoFilter();
            var source = new InMemoryLogFile();

            using (var logFile = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, source, filter, null))
            {
                source.AddEntry("", LevelFlags.None, new DateTime(2017, 12, 11, 19, 34, 0));
                source.AddEntry("", LevelFlags.None, new DateTime(2017, 12, 11, 19, 35, 0));
                _taskScheduler.RunOnce();

                var deltas = logFile.GetColumn(new LogFileSection(0, 2), LogFileColumns.DeltaTime);
                deltas.Should().NotBeNull();
                deltas.Should().HaveCount(2);
                deltas[0].Should().BeNull();
                deltas[1].Should().Be(TimeSpan.FromMinutes(1));
            }
        }
        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));
        }
Exemple #24
0
        public void TestClear3()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hi", LevelFlags.Info);
            logFile.MaxCharactersPerLine.Should().Be(2);
            logFile.Clear();
            logFile.MaxCharactersPerLine.Should().Be(0);
        }
        public void TestMergeMultiline1()
        {
            var logFile1  = new InMemoryLogFile();
            var source1Id = new LogLineSourceId(0);
            var source1   = new SingleDataSource(_taskScheduler,
                                                 new DataSource {
                Id = DataSourceId.CreateNew()
            },
                                                 logFile1,
                                                 TimeSpan.Zero);

            var logFile2  = new InMemoryLogFile();
            var source2Id = new LogLineSourceId(1);
            var source2   = new SingleDataSource(_taskScheduler,
                                                 new DataSource {
                Id = DataSourceId.CreateNew()
            },
                                                 logFile2,
                                                 TimeSpan.Zero);

            _merged.IsSingleLine = false;
            _merged.Add(source1);
            _merged.Add(source2);

            var t1 = new DateTime(2017, 11, 26, 14, 26, 0);

            logFile1.AddEntry("Hello, World!", LevelFlags.Info, t1);

            var t2 = new DateTime(2017, 11, 26, 14, 27, 0);

            logFile2.AddEntry("foo", LevelFlags.Trace, t2);
            logFile2.AddEntry("bar", LevelFlags.None);

            var t3 = new DateTime(2017, 11, 26, 14, 28, 0);

            logFile1.AddEntry("Houston, we have a problem", LevelFlags.Warning, t3);

            _taskScheduler.Run(4);             //< There's a few proxies involved and thus one round won't do it
            _merged.FilteredLogFile.Count.Should().Be(4, "because there are four lines in total, each of which has a timestamp");
            _merged.FilteredLogFile.GetLine(0).Should().Be(new LogLine(0, 0, source1Id, "Hello, World!", LevelFlags.Info, t1));
            _merged.FilteredLogFile.GetLine(1).Should().Be(new LogLine(1, 1, source2Id, "foo", LevelFlags.Trace, t2));
            _merged.FilteredLogFile.GetLine(2).Should().Be(new LogLine(2, 1, source2Id, "bar", LevelFlags.Trace, t2));
            _merged.FilteredLogFile.GetLine(3).Should().Be(new LogLine(3, 2, source1Id, "Houston, we have a problem", LevelFlags.Warning, t3));
        }
Exemple #26
0
        public void TestGetTimestamp2()
        {
            var filter = new LevelFilter(LevelFlags.Error);
            var source = new InMemoryLogFile();

            using (var logFile = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, source, filter, null))
            {
                var timestamp1 = new DateTime(2017, 12, 11, 20, 46, 0);
                source.AddEntry("", LevelFlags.Warning, timestamp1);

                var timestamp2 = new DateTime(2017, 12, 11, 20, 50, 0);
                source.AddEntry("", LevelFlags.Error, timestamp2);
                _taskScheduler.RunOnce();

                var timestamps = logFile.GetColumn(new LogFileSection(0, 1), LogFileColumns.Timestamp);
                timestamps.Should().NotBeNull();
                timestamps.Should().Equal(new object[] { timestamp2 }, "because the first entry doesn't match the filter and thus the timestamp of the 2nd one should've been returned");
            }
        }
Exemple #27
0
        public void TestGetDeltaTime3()
        {
            var filter = new LevelFilter(LevelFlags.Info);
            var source = new InMemoryLogFile();

            using (var logFile = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, source, filter, null))
            {
                source.AddEntry("", LevelFlags.Info, new DateTime(2017, 12, 11, 19, 34, 0));
                source.AddEntry("", LevelFlags.Debug, new DateTime(2017, 12, 11, 19, 35, 0));
                source.AddEntry("", LevelFlags.Info, new DateTime(2017, 12, 11, 19, 36, 0));
                _taskScheduler.RunOnce();

                var deltas = logFile.GetColumn(new LogFileSection(0, 2), LogFileColumns.DeltaTime);
                deltas.Should().NotBeNull();
                deltas.Should().HaveCount(2);
                deltas[0].Should().BeNull();
                deltas[1].Should().Be(TimeSpan.FromMinutes(2), "because the delta time should be calculated based on events which match the filter");
            }
        }
Exemple #28
0
        public void TestSelectMultipleLinesWithKeyboard3()
        {
            var logFile = new InMemoryLogFile();

            logFile.AddEntry("Hello", LevelFlags.None);
            logFile.AddEntry("World", LevelFlags.None);
            logFile.AddEntry("How's it going?", LevelFlags.None);

            _control.LogFile = logFile;
            _control.UpdateVisibleSection();
            _control.UpdateVisibleLines();

            _mouse.LeftClickAt(_control, new Point(10, 24));
            _control.SelectedIndices.Should().Equal(new LogLineIndex(1));

            _keyboard.Press(Key.LeftShift);
            _keyboard.Click(_control, Key.Down);
            _control.SelectedIndices.Should().Equal(new LogLineIndex(1), new LogLineIndex(2));
        }
Exemple #29
0
        public void TestMerge4()
        {
            var source1 = new InMemoryLogFile();
            var source2 = new InMemoryLogFile();
            var merged  = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source1, source2);
            var data    = Listen(merged);

            source1.AddEntry("a", LevelFlags.Warning, new DateTime(2019, 5, 28, 22, 40, 0));
            source1.AddEntry("b", LevelFlags.Info);
            source1.AddEntry("c", LevelFlags.Error, new DateTime(2019, 5, 28, 22, 41, 0));

            _taskScheduler.RunOnce();
            merged.Count.Should().Be(2);
            data.Should().Equal(new object[]
            {
                new LogLine(0, 0, 0, "a", LevelFlags.Warning, new DateTime(2019, 5, 28, 22, 40, 0)),
                new LogLine(1, 1, 1, "c", LevelFlags.Error, new DateTime(2019, 5, 28, 22, 41, 0))
            });
        }
Exemple #30
0
        public void TestGetTimestamp4()
        {
            var source = new InMemoryLogFile();

            var timestamp1 = new DateTime(2017, 12, 11, 20, 33, 0);

            source.AddEntry("", LevelFlags.Debug, timestamp1);

            var timestamp2 = new DateTime(2017, 12, 11, 20, 34, 0);

            source.AddEntry("", LevelFlags.Debug, timestamp2);
            source.AddEntry("", LevelFlags.None);

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

            var timestamps = logFile.GetColumn(new LogFileSection(1, 2), LogFileColumns.Timestamp);

            timestamps.Should().NotBeNull();
            timestamps.Should().Equal(new object[] { timestamp2, timestamp2 });
        }