Exemple #1
0
        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();
        }
Exemple #2
0
        public void TestTwoEntriesDescendingTimestamp()
        {
            var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero);

            _sourceEntries.Add(new LogEntry
            {
                Index     = 0,
                Timestamp = new DateTime(2021, 02, 20, 18, 03, 37)
            });
            _listeners.OnRead(_sourceEntries.Count);
            _scheduler.RunOnce();

            adorner.GetProperty(Core.Properties.StartTimestamp).Should().Be(new DateTime(2021, 02, 20, 18, 03, 37));
            adorner.GetProperty(Core.Properties.EndTimestamp).Should().Be(new DateTime(2021, 02, 20, 18, 03, 37));
            adorner.GetProperty(Core.Properties.Duration).Should().Be(TimeSpan.Zero);

            _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, 18, 02, 12));
            adorner.GetProperty(Core.Properties.EndTimestamp).Should().Be(new DateTime(2021, 02, 20, 18, 03, 37));
            adorner.GetProperty(Core.Properties.Duration).Should().Be(TimeSpan.FromSeconds(85));

            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, 18, 02, 12));
            buffer.GetValue(Core.Properties.EndTimestamp).Should().Be(new DateTime(2021, 02, 20, 18, 03, 37));
            buffer.GetValue(Core.Properties.Duration).Should().Be(TimeSpan.FromSeconds(85));
        }
Exemple #3
0
        public void TestSetProperty()
        {
            var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero);

            adorner.SetProperty(TextProperties.OverwrittenEncoding, Encoding.BigEndianUnicode);
            _source.Verify(x => x.SetProperty(TextProperties.OverwrittenEncoding, Encoding.BigEndianUnicode), Times.Once);

            adorner.SetProperty((IPropertyDescriptor)TextProperties.OverwrittenEncoding, Encoding.BigEndianUnicode);
            _source.Verify(x => x.SetProperty((IPropertyDescriptor)TextProperties.OverwrittenEncoding, Encoding.BigEndianUnicode), Times.Once);
        }
Exemple #4
0
        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");
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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");
        }
Exemple #7
0
        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");
        }
Exemple #8
0
        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();
        }
Exemple #9
0
        public void TestGetPartiallyAdornedProperties()
        {
            var adorner = new LogSourcePropertyAdorner(_scheduler, _source.Object, TimeSpan.Zero);

            _sourceEntries.Add(new LogEntry
            {
                Index     = 0,
                Timestamp = new DateTime(2021, 02, 20, 18, 31, 45)
            });
            _listeners.OnRead(_sourceEntries.Count);
            _sourceProperties.SetValue(TextProperties.Encoding, Encoding.UTF32);
            _scheduler.RunOnce();

            var buffer = new PropertiesBufferList();

            adorner.GetAllProperties(buffer);
            buffer.GetValue(Core.Properties.StartTimestamp).Should().Be(new DateTime(2021, 02, 20, 18, 31, 45));
            buffer.GetValue(Core.Properties.EndTimestamp).Should().Be(new DateTime(2021, 02, 20, 18, 31, 45));
            buffer.GetValue(TextProperties.Encoding).Should().Be(Encoding.UTF32, "because those properties which are not adorned should have been retrieved from the source");
        }