Пример #1
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);
        }
Пример #2
0
        public void TestGetTimestampsOneSource2([Range(0, 3)] int offset)
        {
            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));
            source.AddEntry("", LevelFlags.Other, new DateTime(2017, 12, 14, 23, 29, 1));
            int count = source.Count;

            _taskScheduler.Run(2);

            var buffer = new DateTime?[offset + count];

            for (int i = 0; i < offset + count; ++i)
            {
                buffer[i] = DateTime.MinValue;
            }

            logFile.GetColumn(new LogLineIndex[] { 2, 1 }, LogFileColumns.Timestamp, buffer, offset);

            for (int i = 0; i < offset; ++i)
            {
                buffer[i].Should().Be(DateTime.MinValue, "because we've specified an offset and thus values before that offset shouldn't have been touched");
            }
            buffer[offset + 0].Should().Be(source.GetLine(2).Timestamp);
            buffer[offset + 1].Should().Be(source.GetLine(1).Timestamp);
        }
Пример #3
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
            });
        }