public void TestMergeResetOneSource() { var source1 = new InMemoryLogSource(); var source2 = new InMemoryLogSource(); var merged = new MergedLogSource(_taskScheduler, TimeSpan.Zero, source1, source2); var entries = Listen(merged); var changes = ListenToChanges(merged, 100); source2.AddEntry("a", LevelFlags.Warning, new DateTime(2021, 2, 28, 22, 15, 0)); source1.AddEntry("b", LevelFlags.Info, new DateTime(2021, 2, 28, 22, 16, 0)); source2.AddEntry("c", LevelFlags.Error, new DateTime(2021, 2, 28, 22, 17, 0)); _taskScheduler.RunOnce(); merged.GetProperty(Core.Properties.PercentageProcessed).Should().Be(Percentage.HundredPercent); entries.Count.Should().Be(3); changes.Should().Equal(new object[] { LogSourceModification.Reset(), LogSourceModification.Appended(0, 3) }); source1.Clear(); _taskScheduler.RunOnce(); entries.Count.Should().Be(2, "because the one entry from source should have been removed from the merged source"); changes.Should().Equal(new object[] { LogSourceModification.Reset(), LogSourceModification.Appended(0, 3), LogSourceModification.Removed(1, 2), LogSourceModification.Appended(1, 1) }); }
public void TestClear3() { var logFile = new InMemoryLogSource(); logFile.AddEntry("Hi", LevelFlags.Info); logFile.GetProperty(TextProperties.MaxCharactersInLine).Should().Be(2); logFile.Clear(); logFile.GetProperty(TextProperties.MaxCharactersInLine).Should().Be(0); }
public void TestClear2() { var logFile = new InMemoryLogSource(); logFile.AddEntry("Hello,", LevelFlags.Info); logFile.AddEntry(" World!", LevelFlags.Warning); logFile.Clear(); logFile.Count.Should().Be(0); }
public void TestClear4() { var logFile = new InMemoryLogSource(); logFile.AddEntry("Hi", LevelFlags.Info); logFile.GetProperty(TextProperties.MaxCharactersInLine).Should().Be(2); logFile.AddListener(_listener.Object, TimeSpan.Zero, 1); logFile.Clear(); _modifications.Should().EndWith(LogSourceModification.Reset()); }
public void TestClear1() { var logFile = new InMemoryLogSource(); logFile.Clear(); logFile.GetProperty(Core.Properties.Size).Should().Be(Size.Zero); logFile.GetProperty(TextProperties.MaxCharactersInLine).Should().Be(0); logFile.GetProperty(Core.Properties.LastModified).Should().BeNull(); logFile.GetProperty(Core.Properties.StartTimestamp).Should().BeNull(); logFile.GetProperty(Core.Properties.EndTimestamp).Should().BeNull(); logFile.GetProperty(Core.Properties.Duration).Should().BeNull(); logFile.GetProperty(Core.Properties.EmptyReason).Should().Be(null); logFile.Count.Should().Be(0); }
public void TestGetLogLineIndexOfOriginalLineIndex2() { var logFile = new InMemoryLogSource(); 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); }
public void TestReset() { var logFile = new InMemoryLogSource(); logFile.AddEntry("What's up people?"); logFile.AddEntry("Hello World!"); logFile.AddEntry("Looks like a bug"); using (var search = new LogSourceSearch(_scheduler, logFile, "l", TimeSpan.Zero)) { _scheduler.RunOnce(); search.Matches.Should().HaveCount(6); logFile.Clear(); search.Matches.Should().HaveCount(6); _scheduler.RunOnce(); search.Matches.Should().HaveCount(0, "because we've cleared the log source"); } }