public void TestMergeMultiline4() { var source = new InMemoryLogFile(); var merged = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source); source.AddMultilineEntry(LevelFlags.Other, new DateTime(2017, 12, 3, 11, 59, 30), new [] { "2017-12-03 11:59:30 Hello, ", "World!" }); _taskScheduler.RunOnce(); merged.Count.Should().Be(2); var entries = merged.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!"); }
public void TestMergeMultiline3() { var source1 = new InMemoryLogFile(); var source1Id = new LogLineSourceId(0); var source2 = new InMemoryLogFile(); var source2Id = new LogLineSourceId(1); var merged = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source1, source2); var t1 = new DateTime(2017, 11, 26, 11, 45, 0); source1.AddEntry("Foo", LevelFlags.Info, t1); _taskScheduler.RunOnce(); var t3 = new DateTime(2017, 11, 26, 11, 45, 2); source1.AddEntry("bar", LevelFlags.Warning, t3); _taskScheduler.RunOnce(); var t2 = new DateTime(2017, 11, 26, 11, 45, 1); source2.AddMultilineEntry(LevelFlags.Debug, t2, "Hello,", "World!"); _taskScheduler.RunOnce(); merged.Count.Should().Be(4); merged.GetLine(0).Should().Be(new LogLine(0, 0, source1Id, "Foo", LevelFlags.Info, t1)); merged.GetLine(1).Should().Be(new LogLine(1, 1, source2Id, "Hello,", LevelFlags.Debug, t2)); merged.GetLine(2).Should().Be(new LogLine(2, 1, source2Id, "World!", LevelFlags.Debug, t2)); merged.GetLine(3).Should().Be(new LogLine(3, 2, source1Id, "bar", LevelFlags.Warning, t3)); }
public void TestAddMultilineEntry3() { var logFile = new InMemoryLogFile(); var t1 = new DateTime(2017, 11, 26, 11, 56, 0); logFile.AddMultilineEntry(LevelFlags.Info, t1, "foo", "bar"); var t2 = new DateTime(2017, 11, 26, 11, 57, 0); logFile.AddMultilineEntry(LevelFlags.Warning, t2, "H", "e", "l", "l", "o"); logFile.Count.Should().Be(7); logFile.GetLine(0).Should().Be(new LogLine(0, 0, "foo", LevelFlags.Info, t1)); logFile.GetLine(1).Should().Be(new LogLine(1, 0, "bar", LevelFlags.Info, t1)); logFile.GetLine(2).Should().Be(new LogLine(2, 1, "H", LevelFlags.Warning, t2)); logFile.GetLine(3).Should().Be(new LogLine(3, 1, "e", LevelFlags.Warning, t2)); logFile.GetLine(4).Should().Be(new LogLine(4, 1, "l", LevelFlags.Warning, t2)); logFile.GetLine(5).Should().Be(new LogLine(5, 1, "l", LevelFlags.Warning, t2)); logFile.GetLine(6).Should().Be(new LogLine(6, 1, "o", LevelFlags.Warning, t2)); }
public void TestAddMultilineEntry1() { var logFile = new InMemoryLogFile(); logFile.AddMultilineEntry(LevelFlags.Debug, null, "foo", "bar"); logFile.Count.Should().Be(2); logFile.GetLine(0).Should().Be(new LogLine(0, 0, "foo", LevelFlags.Debug, null)); logFile.GetLine(1).Should().Be(new LogLine(1, 0, "bar", LevelFlags.Debug, null)); }
public void TestAddMultilineEntry2() { var logFile = new InMemoryLogFile(); logFile.AddEntry("Hello, World!", LevelFlags.Debug); var t1 = new DateTime(2017, 11, 26, 11, 56, 0); logFile.AddMultilineEntry(LevelFlags.Info, t1, "foo", "bar"); logFile.Count.Should().Be(3); logFile.GetLine(0).Should().Be(new LogLine(0, 0, "Hello, World!", LevelFlags.Debug, null)); logFile.GetLine(1).Should().Be(new LogLine(1, 1, "foo", LevelFlags.Info, t1)); logFile.GetLine(2).Should().Be(new LogLine(2, 1, "bar", LevelFlags.Info, t1)); }
public void TestAddMultilineEntry4() { var logFile = new InMemoryLogFile(); logFile.AddListener(_listener.Object, TimeSpan.Zero, 2); var t1 = new DateTime(2017, 11, 26, 11, 56, 0); logFile.AddMultilineEntry(LevelFlags.Info, t1, "foo", "bar"); _modifications.Should().Equal(new object[] { LogFileSection.Reset, new LogFileSection(0, 2) }); }