Beispiel #1
0
        public void TestGetOriginalLineNumbersByIndices()
        {
            var filter = new SubstringFilter("B", true);
            var source = new InMemoryLogFile();

            source.Add(new LogEntry2(LogFileColumns.Minimum)
            {
                RawContent = "A"
            });
            source.Add(new LogEntry2(LogFileColumns.Minimum)
            {
                RawContent = "B"
            });
            source.Add(new LogEntry2(LogFileColumns.Minimum)
            {
                RawContent = "A"
            });
            source.Add(new LogEntry2(LogFileColumns.Minimum)
            {
                RawContent = "B"
            });
            var filteredLogFile = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, source, filter, null);

            _taskScheduler.RunOnce();

            filteredLogFile.Count.Should().Be(2);
            var lineNumbers = filteredLogFile.GetColumn(new LogLineIndex[] { 1, 0 }, LogFileColumns.OriginalLineNumber);

            lineNumbers[0].Should().Be(4);
            lineNumbers[1].Should().Be(2);

            lineNumbers = filteredLogFile.GetColumn(new LogLineIndex[] { 1 }, LogFileColumns.OriginalLineNumber);
            lineNumbers[0].Should().Be(4);
        }
        public void TestAddSeveralEntries()
        {
            var logFile = new InMemoryLogFile();
            var index   = new PresentationLogFile(_scheduler, logFile, TimeSpan.Zero);

            logFile.Add(new LogEntry2 {
                RawContent = "Foo"
            });
            _scheduler.RunOnce();
            index.MaximumWidth.Should().BeApproximately(19.8, 0.1);
            index.LineCount.Should().Be(1);

            logFile.Add(new LogEntry2 {
                RawContent = "Hello,\r\nWorld!"
            });
            _scheduler.RunOnce();
            index.MaximumWidth.Should().BeApproximately(46.2, 0.1);
            index.LineCount.Should().Be(3);

            logFile.Add(new LogEntry2 {
                RawContent = "Bar"
            });
            _scheduler.RunOnce();
            index.MaximumWidth.Should().BeApproximately(46.2, 0.1);
            index.LineCount.Should().Be(4);
        }
Beispiel #3
0
        public void TestGetLineNumbersBySection()
        {
            var filter = new SubstringFilter("B", true);
            var source = new InMemoryLogFile();

            source.Add(new LogEntry2(LogFileColumns.Minimum)
            {
                RawContent = "A"
            });
            source.Add(new LogEntry2(LogFileColumns.Minimum)
            {
                RawContent = "B"
            });
            source.Add(new LogEntry2(LogFileColumns.Minimum)
            {
                RawContent = "A"
            });
            source.Add(new LogEntry2(LogFileColumns.Minimum)
            {
                RawContent = "B"
            });
            var filteredLogFile = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, source, filter, null);

            _taskScheduler.RunOnce();

            filteredLogFile.Count.Should().Be(2);
            var lineNumbers = filteredLogFile.GetColumn(new LogFileSection(0, 2), LogFileColumns.LineNumber);

            lineNumbers[0].Should().Be(1);
            lineNumbers[1].Should().Be(2);
        }
Beispiel #4
0
        public void TestGetLineNumbersByIndices()
        {
            var source1 = new InMemoryLogFile();

            source1.Add(new LogEntry2 {
                Timestamp = new DateTime(2017, 12, 20, 23, 1, 0)
            });

            var source2 = new InMemoryLogFile();

            source1.Add(new LogEntry2 {
                Timestamp = new DateTime(2017, 12, 20, 23, 0, 0)
            });

            var logFile = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source1, source2);

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

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

            lineNumbers[0].Should().Be(2);
            lineNumbers[1].Should().Be(1);

            lineNumbers = logFile.GetColumn(new LogLineIndex[] { 1, 0 }, LogFileColumns.OriginalLineNumber);
            lineNumbers[0].Should().Be(2);
            lineNumbers[1].Should().Be(1);
        }
        public void TestTwoLines()
        {
            var logFile = new InMemoryLogFile();
            var index   = new PresentationLogFile(_scheduler, logFile, TimeSpan.Zero);

            logFile.Add(new LogEntry2 {
                RawContent = "Hello,\r\nWorld!"
            });

            _scheduler.RunOnce();
            index.MaximumWidth.Should().BeApproximately(46, 1);
            index.LineCount.Should().Be(2);
        }
        public void TestOneLine()
        {
            var logFile = new InMemoryLogFile();
            var index   = new PresentationLogFile(_scheduler, logFile, TimeSpan.Zero, TextSettings.Default);

            logFile.Add(new LogEntry2 {
                RawContent = "Hello, World!"
            });

            _scheduler.RunOnce();
            index.MaximumWidth.Should().BeApproximately(85, 1);
            index.LineCount.Should().Be(1);
        }
Beispiel #7
0
        public void TestAddEntry6()
        {
            var logFile = new InMemoryLogFile(LogFileColumns.LogLevel);

            var logEntry = new LogEntry2();

            logEntry.Add(LogFileColumns.LogLevel, LevelFlags.Error);
            logFile.Add(logEntry);

            var buffer = new LogEntryBuffer(1, LogFileColumns.LogLevel);

            logFile.GetEntries(new LogFileSection(0, 1), buffer);
            buffer[0].LogLevel.Should().Be(LevelFlags.Error);
        }
        public void TestPartialInvalidate()
        {
            var logFile = new InMemoryLogFile();
            var index   = new PresentationLogFile(_scheduler, logFile, TimeSpan.Zero, TextSettings.Default);

            logFile.Add(new LogEntry2 {
                RawContent = "Foo"
            });
            _scheduler.RunOnce();
            index.MaximumWidth.Should().BeApproximately(19.8, 0.1);
            index.LineCount.Should().Be(1);

            logFile.Add(new LogEntry2 {
                RawContent = "Hello,\r\nWorld!"
            });
            _scheduler.RunOnce();
            index.MaximumWidth.Should().BeApproximately(46.2, 0.1);
            index.LineCount.Should().Be(3);

            logFile.RemoveFrom(1);
            _scheduler.RunOnce();
            index.MaximumWidth.Should().BeApproximately(19.8, 0.1);
            index.LineCount.Should().Be(1);
        }