public void Test2SmallSources() { using (var source0 = new TextLogFile(_scheduler, TextLogFileAcceptanceTest.File2Entries)) using (var source1 = new TextLogFile(_scheduler, TextLogFileAcceptanceTest.File2Lines)) using (var multi0 = new MultiLineLogFile(_scheduler, source0, TimeSpan.Zero)) using (var multi1 = new MultiLineLogFile(_scheduler, source1, TimeSpan.Zero)) using (var merged = new MergedLogFile(_scheduler, TimeSpan.Zero, multi0, multi1)) { source0.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(); source1.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(); multi0.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(); multi1.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(); merged.Property(x => x.Count).ShouldEventually().Be(8, TimeSpan.FromSeconds(5), "Because the merged file should've been finished"); merged.Property(x => x.GetValue(LogFileProperties.Size)).ShouldEventually().Be(source0.GetValue(LogFileProperties.Size) + source1.GetValue(LogFileProperties.Size)); merged.Property(x => x.GetValue(LogFileProperties.StartTimestamp)).ShouldEventually().Be(source1.GetValue(LogFileProperties.StartTimestamp)); LogLine[] source0Lines = multi0.GetSection(new LogFileSection(0, source0.Count)); LogLine[] source1Lines = multi1.GetSection(new LogFileSection(0, source1.Count)); LogLine[] mergedLines = merged.GetSection(new LogFileSection(0, merged.Count)); mergedLines[0].Should().Be(new LogLine(0, 0, new LogLineSourceId(1), source1Lines[0])); mergedLines[1].Should().Be(new LogLine(1, 1, new LogLineSourceId(0), source0Lines[0])); mergedLines[2].Should().Be(new LogLine(2, 1, new LogLineSourceId(0), source0Lines[1])); mergedLines[3].Should().Be(new LogLine(3, 1, new LogLineSourceId(0), source0Lines[2])); mergedLines[4].Should().Be(new LogLine(4, 2, new LogLineSourceId(1), source1Lines[1])); mergedLines[5].Should().Be(new LogLine(5, 3, new LogLineSourceId(0), source0Lines[3])); mergedLines[6].Should().Be(new LogLine(6, 3, new LogLineSourceId(0), source0Lines[4])); mergedLines[7].Should().Be(new LogLine(7, 3, new LogLineSourceId(0), source0Lines[5])); } }
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"); } }
public void TestMultilineNoLevel3() { 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 line = multi.GetLine(0); line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 177)); line.LogEntryIndex.Should().Be(0); line.LineIndex.Should().Be(0); line.Message.Should().Be("2019-03-18 14:09:54:177 1 00:00:00:0000000 Information Initialize Globals"); line = multi.GetLine(1); line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 177)); line.LogEntryIndex.Should().Be(0); line.LineIndex.Should().Be(1); line.Message.Should().Be("Started BTPVM3372 05:30:00 6060"); line = multi.GetLine(2); line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 313)); line.LogEntryIndex.Should().Be(1); line.LineIndex.Should().Be(2); line.Message.Should().Be("2019-03-18 14:09:54:313 1 00:00:00:0000000 Information Loading"); line = multi.GetLine(3); line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 313)); line.LogEntryIndex.Should().Be(1); line.LineIndex.Should().Be(3); line.Message.Should().Be("preferences Started BTPVM3372 05:30:00 6060"); line = multi.GetLine(4); line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 551)); line.LogEntryIndex.Should().Be(2); line.LineIndex.Should().Be(4); line.Message.Should().Be("2019-03-18 14:09:54:551 1 00:00:00:0000000 Information RMClientURL:"); line = multi.GetLine(5); line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 551)); line.LogEntryIndex.Should().Be(2); line.LineIndex.Should().Be(5); line.Message.Should().Be("BTPVM3372 05:30:00 6060"); } }