public void TestTwoEntriesAscendingTimestamp() { var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero); _sourceEntries.Add(new LogEntry { Index = 0, Timestamp = new DateTime(2021, 02, 20, 17, 52, 31) }); _listeners.OnRead(_sourceEntries.Count); _scheduler.RunOnce(); _sourceEntries.Add(new LogEntry { Index = 1, Timestamp = new DateTime(2021, 02, 20, 18, 02, 12) }); _listeners.OnRead(_sourceEntries.Count); _scheduler.RunOnce(); adorner.GetProperty(Core.Properties.StartTimestamp).Should().Be(new DateTime(2021, 02, 20, 17, 52, 31)); adorner.GetProperty(Core.Properties.EndTimestamp).Should().Be(new DateTime(2021, 02, 20, 18, 02, 12)); adorner.GetProperty(Core.Properties.Duration).Should().Be(TimeSpan.FromSeconds(581)); var buffer = new PropertiesBufferList(Core.Properties.StartTimestamp, Core.Properties.EndTimestamp); adorner.GetAllProperties(buffer); buffer.GetValue(Core.Properties.StartTimestamp).Should().Be(new DateTime(2021, 02, 20, 17, 52, 31)); buffer.GetValue(Core.Properties.EndTimestamp).Should().Be(new DateTime(2021, 02, 20, 18, 02, 12)); adorner.GetProperty(Core.Properties.Duration).Should().Be(TimeSpan.FromSeconds(581)); }
public void TestGetNonAdornedProperty() { var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero); var format = new Mock <ILogFileFormat>(); _sourceProperties.SetValue(Core.Properties.Format, format.Object); _scheduler.RunOnce(); adorner.GetProperty(Core.Properties.Format).Should().Be(format.Object, "because the adorner should forward GetProperty calls to the source when they aren't adorned and return its return value"); adorner.GetProperty((IReadOnlyPropertyDescriptor)Core.Properties.Format).Should().Be(format.Object, "because the adorner should forward GetProperty calls to the source when they aren't adorned and return its return value"); }
public void TestOneEntryNoTimestampColumn() { var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero); _scheduler.RunOnce(); adorner.GetProperty(Core.Properties.StartTimestamp).Should().BeNull(); adorner.GetProperty(Core.Properties.EndTimestamp).Should().BeNull(); adorner.GetProperty(Core.Properties.Duration).Should().BeNull(); var buffer = new PropertiesBufferList(Core.Properties.StartTimestamp, Core.Properties.EndTimestamp); adorner.GetAllProperties(buffer); buffer.GetValue(Core.Properties.StartTimestamp).Should().BeNull(); buffer.GetValue(Core.Properties.EndTimestamp).Should().BeNull(); buffer.GetValue(Core.Properties.Duration).Should().BeNull(); }
public void TestOneEntryTimestampReset() { var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero); _sourceEntries.Add(new LogEntry { Index = 0, Timestamp = new DateTime(2021, 02, 20, 17, 52, 31) }); _listeners.OnRead(_sourceEntries.Count); _scheduler.RunOnce(); adorner.GetProperty(Core.Properties.StartTimestamp).Should().Be(new DateTime(2021, 02, 20, 17, 52, 31)); adorner.GetProperty(Core.Properties.EndTimestamp).Should().Be(new DateTime(2021, 02, 20, 17, 52, 31)); adorner.GetProperty(Core.Properties.Duration).Should().Be(TimeSpan.Zero); var buffer = new PropertiesBufferList(Core.Properties.StartTimestamp, Core.Properties.EndTimestamp); adorner.GetAllProperties(buffer); buffer.GetValue(Core.Properties.StartTimestamp).Should().Be(new DateTime(2021, 02, 20, 17, 52, 31)); buffer.GetValue(Core.Properties.EndTimestamp).Should().Be(new DateTime(2021, 02, 20, 17, 52, 31)); buffer.GetValue(Core.Properties.Duration).Should().Be(TimeSpan.Zero); _sourceEntries.Clear(); _listeners.Reset(); _scheduler.RunOnce(); adorner.GetProperty(Core.Properties.StartTimestamp).Should().BeNull(); adorner.GetProperty(Core.Properties.EndTimestamp).Should().BeNull(); adorner.GetProperty(Core.Properties.Duration).Should().BeNull(); adorner.GetAllProperties(buffer); buffer.GetValue(Core.Properties.StartTimestamp).Should().BeNull(); buffer.GetValue(Core.Properties.EndTimestamp).Should().BeNull(); buffer.GetValue(Core.Properties.Duration).Should().BeNull(); }
public void TestConstruction() { var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero); adorner.Properties.Should().Contain(LogSourcePropertyAdorner.AllAdornedProperties); adorner.GetProperty(Core.Properties.PercentageProcessed).Should().Be(Percentage.Zero, "because no processing has been done just yet"); var buffer = new PropertiesBufferList(); adorner.GetAllProperties(buffer); buffer.GetValue(Core.Properties.PercentageProcessed).Should().Be(Percentage.Zero, "because no processing has been done just yet"); }
public void TestEmptySourceFinishedProcessing() { var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero); _sourceProperties.SetValue(Core.Properties.PercentageProcessed, Percentage.HundredPercent); _scheduler.RunOnce(); adorner.GetProperty(Core.Properties.PercentageProcessed).Should().Be(Percentage.HundredPercent, "because both the source and adorner are finished processing"); var buffer = new PropertiesBufferList(); adorner.GetAllProperties(buffer); buffer.GetValue(Core.Properties.PercentageProcessed).Should().Be(Percentage.HundredPercent, "because both the source and adorner are finished processing"); }
public void TestLogLevelFatal() { var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero); _sourceEntries.Add(new LogEntry { Index = 0, LogLevel = LevelFlags.Fatal }); _listeners.OnRead(_sourceEntries.Count); _scheduler.RunOnce(); adorner.GetProperty(Core.Properties.TraceLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.DebugLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.InfoLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.WarningLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.ErrorLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.FatalLogEntryCount).Should().Be(1); adorner.GetProperty(Core.Properties.OtherLogEntryCount).Should().Be(0); var buffer = new PropertiesBufferList(Core.Properties.StartTimestamp, Core.Properties.EndTimestamp); adorner.GetAllProperties(buffer); buffer.GetValue(Core.Properties.TraceLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.DebugLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.InfoLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.WarningLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.ErrorLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.FatalLogEntryCount).Should().Be(1); buffer.GetValue(Core.Properties.OtherLogEntryCount).Should().Be(0); _sourceEntries.Clear(); _listeners.Reset(); _scheduler.RunOnce(); adorner.GetProperty(Core.Properties.TraceLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.DebugLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.InfoLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.WarningLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.ErrorLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.FatalLogEntryCount).Should().Be(0); adorner.GetProperty(Core.Properties.OtherLogEntryCount).Should().Be(0); adorner.GetAllProperties(buffer); buffer.GetValue(Core.Properties.TraceLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.DebugLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.InfoLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.WarningLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.ErrorLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.FatalLogEntryCount).Should().Be(0); buffer.GetValue(Core.Properties.OtherLogEntryCount).Should().Be(0); }