public void TestCtor2() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Verify(x => x.AddListener(It.IsAny <ILogSourceListener>(), It.IsAny <TimeSpan>(), It.IsAny <int>()), Times.Once); } }
protected AbstractDataSource(ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime) { if (taskScheduler == null) { throw new ArgumentNullException(nameof(taskScheduler)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (settings.Id == DataSourceId.Empty) { throw new ArgumentException("settings.Id shall be set to an actually generated id"); } _taskScheduler = taskScheduler; _settings = settings; _maximumWaitTime = maximumWaitTime; _logSource = new LogSourceProxy(taskScheduler, maximumWaitTime); _search = new LogSourceSearchProxy(taskScheduler, _logSource, maximumWaitTime); _findAllLogSource = new LogSourceProxy(taskScheduler, maximumWaitTime); _findAllSearch = new LogSourceSearchProxy(taskScheduler, _findAllLogSource, maximumWaitTime); UpdateSearch(); UpdateFindAllSearch(); }
public void TestGetLine_NoSource() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, null)) { var entry = proxy.GetEntry(0); entry.Index.Should().Be(LogLineIndex.Invalid); } }
protected override ILogSource CreateFromContent(IReadOnlyLogBuffer content) { var source = new InMemoryLogSource(content); var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, source); _taskScheduler.RunOnce(); return(proxy); }
public void TestConstruction() { _logFile.Setup(x => x.Columns).Returns(new[] { Core.Columns.RawContent }); using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { proxy.Columns.Should().Equal(Core.Columns.RawContent); } }
public void TestInnerLogFile1() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { proxy.InnerLogSource = null; _logFile.Verify(x => x.RemoveListener(It.IsAny <ILogSourceListener>()), Times.Once); } }
public void TestDispose2() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { proxy.Dispose(); _logFile.Verify(l => l.Dispose(), Times.Once); } }
public void TestGetLogLineIndexOfOriginalLineIndex2() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero)) { proxy.GetLogLineIndexOfOriginalLineIndex(new LogLineIndex(9001)) .Should() .Be(LogLineIndex.Invalid, "because the proxy should just return an invalid index when no inner log file is present"); } }
public void TestGetColumn2() { var section = new LogSourceSection(42, 100); var buffer = new string[100]; var logFile = new LogSourceProxy(_taskScheduler, TimeSpan.Zero); logFile.GetColumn(section, Core.Columns.RawContent, buffer); buffer.Should().OnlyContain(x => ReferenceEquals(x, null)); }
public void TestGetColumn3() { var indices = new LogLineIndex[] { 1, 2 }; var buffer = new string[2]; var logFile = new LogSourceProxy(_taskScheduler, TimeSpan.Zero); logFile.GetColumn(indices, Core.Columns.RawContent, buffer); buffer.Should().OnlyContain(x => ReferenceEquals(x, null)); }
public MergedDataSource(ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime) : base(taskScheduler, settings, maximumWaitTime) { _dataSources = new List <IDataSource>(); _unfilteredLogSource = new LogSourceProxy(taskScheduler, TimeSpan.Zero); OriginalSources = new IDataSource[0]; UpdateUnfilteredLogFile(); OnUnfilteredLogFileChanged(); }
public void TestGetEntry() { var source = new InMemoryLogSource(); source.AddEntry("I'm an english man in new york"); using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, source)) { var entry = proxy.GetEntry(0); entry.RawContent.Should().Be("I'm an english man in new york"); } }
public void TestDispose1() { var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero); _taskScheduler.PeriodicTaskCount.Should().Be(1); proxy.IsDisposed.Should().BeFalse(); new Action(proxy.Dispose).Should().NotThrow(); proxy.IsDisposed.Should().BeTrue(); _taskScheduler.PeriodicTaskCount.Should().Be(0); }
public void TestGetLogLineIndexOfOriginalLineIndex1() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.GetLogLineIndexOfOriginalLineIndex(It.Is <LogLineIndex>(y => y == 9001))) .Returns(42); proxy.GetLogLineIndexOfOriginalLineIndex(new LogLineIndex(9001)) .Should() .Be(new LogLineIndex(42), "because the proxy should forward all requests to the inner log file, if available"); } }
public void TestListen4() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { proxy.AddListener(_listener.Object, TimeSpan.Zero, 1000); new Action(() => proxy.OnLogFileModified(new Mock <ILogSource>().Object, LogSourceModification.Appended(0, 1))).Should().NotThrow(); _modifications.Should().Equal(new[] { LogSourceModification.Reset() }, "because the OnLogFileModified shouldn't have been forwarded since it's from the wrong source"); new Action(() => proxy.OnLogFileModified(null, LogSourceModification.Appended(0, 1))).Should().NotThrow(); _modifications.Should().Equal(new[] { LogSourceModification.Reset() }, "because the OnLogFileModified shouldn't have been forwarded since it's from the wrong source"); } }
public CustomDataSource(ILogSourceFactoryEx logSourceFactory, ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime) : base(taskScheduler, settings, maximumWaitTime) { _originalLogFile = logSourceFactory.CreateCustom(settings.CustomDataSourceId, settings.CustomDataSourceConfiguration, out _pluginDescription); _unfilteredLogFile = new LogSourceProxy(TaskScheduler, MaximumWaitTime); OnSingleLineChanged(); OnUnfilteredLogFileChanged(); }
public FileDataSource(ITaskScheduler taskScheduler, DataSource settings, ILogSource unfilteredLogSource, TimeSpan maximumWaitTime) : base(taskScheduler, settings, maximumWaitTime) { if (unfilteredLogSource == null) { throw new ArgumentNullException(nameof(unfilteredLogSource)); } _originalLogSource = unfilteredLogSource; _unfilteredLogSource = new LogSourceProxy(TaskScheduler, MaximumWaitTime); OnSingleLineChanged(); OnUnfilteredLogFileChanged(); }
public FileDataSource(ILogSourceFactory logSourceFactory, ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime) : base(taskScheduler, settings, maximumWaitTime) { if (logSourceFactory == null) { throw new ArgumentNullException(nameof(logSourceFactory)); } _originalLogSource = logSourceFactory.Open(settings.File); _unfilteredLogSource = new LogSourceProxy(TaskScheduler, MaximumWaitTime); OnSingleLineChanged(); OnUnfilteredLogFileChanged(); }
public void TestListen1() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { proxy.AddListener(_listener.Object, TimeSpan.FromSeconds(1), 1000); proxy.OnLogFileModified(_logFile.Object, LogSourceModification.Appended(0, 1)); _modifications.Property(x => x.Count).ShouldEventually().Be(2); _modifications.Should().Equal(new[] { LogSourceModification.Reset(), LogSourceModification.Appended(0, 1) }); } }
public void TestGetSection() { var source = new InMemoryLogSource(); source.AddEntry("Sting"); source.AddEntry("I'm an english man in new york"); source.AddEntry("1987"); using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, source)) { var entries = proxy.GetEntries(new LogSourceSection(1, 2)); entries[0].Index.Should().Be(1); entries[0].RawContent.Should().Be("I'm an english man in new york"); entries[1].Index.Should().Be(2); entries[1].RawContent.Should().Be("1987"); } }
public void TestGetColumn1() { var section = new LogSourceSection(42, 100); var buffer = new string[142]; var logFile = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object); var destinationIndex = 42; var queryOptions = new LogSourceQueryOptions(LogSourceQueryMode.FromCache); logFile.GetColumn(section, Core.Columns.RawContent, buffer, destinationIndex, queryOptions); _logFile.Verify(x => x.GetColumn(It.Is <LogSourceSection>(y => y == section), Core.Columns.RawContent, buffer, destinationIndex, queryOptions), Times.Once); }
public void TestEmptyConstruction() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero)) { proxy.InnerLogSource.Should().BeNull(); proxy.GetProperty(TextProperties.MaxCharactersInLine).Should().Be(0); proxy.GetProperty(Core.Properties.EmptyReason).Should().Be(null); proxy.GetProperty(Core.Properties.Size).Should().BeNull(); proxy.GetProperty(Core.Properties.StartTimestamp).Should().NotHaveValue(); proxy.GetProperty(Core.Properties.EndTimestamp).Should().NotHaveValue(); proxy.GetProperty(Core.Properties.LogEntryCount).Should().Be(0); proxy.Columns.Should().Equal(Core.Columns.Minimum); proxy.GetEntry(0).Index.Should().Be(LogLineIndex.Invalid); } }
public void TestCount() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.GetAllProperties(It.IsAny <IPropertiesBuffer>())) .Callback((IPropertiesBuffer destination) => destination.SetValue(Core.Properties.LogEntryCount, 42)); _taskScheduler.RunOnce(); proxy.GetProperty(Core.Properties.LogEntryCount).Should().Be(42); _logFile.Setup(x => x.GetAllProperties(It.IsAny <IPropertiesBuffer>())) .Callback((IPropertiesBuffer destination) => destination.SetValue(Core.Properties.LogEntryCount, 9001)); _taskScheduler.RunOnce(); proxy.GetProperty(Core.Properties.LogEntryCount).Should().Be(9001); } }
public void TestProgress2() { var logFile = new LogSourceProxy(_taskScheduler, TimeSpan.Zero); _logFile.Setup(x => x.GetAllProperties(It.IsAny <IPropertiesBuffer>())) .Callback((IPropertiesBuffer destination) => { destination.SetValue(Core.Properties.PercentageProcessed, Percentage.FiftyPercent); }); logFile.InnerLogSource = _logFile.Object; logFile.GetProperty(Core.Properties.PercentageProcessed).Should() .Be(Percentage.Zero, "because the proxy didn't process anything just yet"); _taskScheduler.RunOnce(); logFile.GetProperty(Core.Properties.PercentageProcessed).Should() .Be(Percentage.FiftyPercent, "because while the proxy is done, its source is only half finished"); }
public FolderDataSource(ITaskScheduler taskScheduler, ILogSourceFactory logSourceFactory, IFilesystem filesystem, DataSource settings, TimeSpan maximumWaitTime) { _taskScheduler = taskScheduler; _logSourceFactory = logSourceFactory; _filesystem = filesystem; _settings = settings; _syncRoot = new object(); _dataSources = new Dictionary <IFileInfo, FileDataSource>(); _mergedDataSource = new MergedDataSource(taskScheduler, settings, maximumWaitTime); _unfilteredLogSourceProxy = new LogSourceProxy(taskScheduler, maximumWaitTime); _filteredLogSourceProxy = new LogSourceProxy(taskScheduler, maximumWaitTime); DoChange(); }
public void TestListen1() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object, 1000)) { proxy.AddListener(_listener.Object, TimeSpan.Zero, 1000); _listeners.OnRead(500); _listeners.OnRead(600); _taskScheduler.RunOnce(); _modifications.Should().Equal(new[] { LogSourceModification.Reset(), LogSourceModification.Appended(0, 500), LogSourceModification.Appended(500, 100) }); } }
public void TestMaxCharactersPerLine() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.GetAllProperties(It.IsAny <IPropertiesBuffer>())) .Callback((IPropertiesBuffer destination) => { destination.SetValue(TextProperties.MaxCharactersInLine, 101); }); _taskScheduler.RunOnce(); proxy.GetProperty(TextProperties.MaxCharactersInLine).Should().Be(101); _logFile.Setup(x => x.GetAllProperties(It.IsAny <IPropertiesBuffer>())) .Callback((IPropertiesBuffer destination) => { destination.SetValue(TextProperties.MaxCharactersInLine, 0); }); _taskScheduler.RunOnce(); proxy.GetProperty(TextProperties.MaxCharactersInLine).Should().Be(0); } }
public void TestFileSize() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.GetAllProperties(It.IsAny <IPropertiesBuffer>())) .Callback((IPropertiesBuffer destination) => { destination.SetValue(Core.Properties.Size, Size.FromBytes(12)); }); _taskScheduler.RunOnce(); proxy.GetProperty(Core.Properties.Size).Should().Be(Size.FromBytes(12)); _logFile.Setup(x => x.GetAllProperties(It.IsAny <IPropertiesBuffer>())) .Callback((IPropertiesBuffer destination) => { destination.SetValue(Core.Properties.Size, Size.OneMegabyte); }); _taskScheduler.RunOnce(); proxy.GetProperty(Core.Properties.Size).Should().Be(Size.OneMegabyte); } }
public void TestStartTimestamp() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.GetAllProperties(It.IsAny <IPropertiesBuffer>())) .Callback((IPropertiesBuffer destination) => { destination.SetValue(Core.Properties.StartTimestamp, new DateTime(2016, 10, 7, 14, 46, 00)); }); _taskScheduler.RunOnce(); proxy.GetProperty(Core.Properties.StartTimestamp).Should().Be(new DateTime(2016, 10, 7, 14, 46, 00)); _logFile.Setup(x => x.GetAllProperties(It.IsAny <IPropertiesBuffer>())) .Callback((IPropertiesBuffer destination) => { destination.SetValue(Core.Properties.StartTimestamp, null); }); _taskScheduler.RunOnce(); proxy.GetProperty(Core.Properties.StartTimestamp).Should().NotHaveValue(); } }
public void TestGetOriginalIndexFrom2() { using (var proxy = new LogSourceProxy(_taskScheduler, TimeSpan.Zero, _logFile.Object)) { var buffer = new LogLineIndex[100]; var destinationIndex = 47; var queryOptions = new LogSourceQueryOptions(LogSourceQueryMode.FromCache); proxy.GetColumn(new LogSourceSection(1, 42), Core.Columns.OriginalIndex, buffer, destinationIndex, queryOptions); _logFile.Verify(x => x.GetColumn(It.Is <LogSourceSection>(y => y == new LogSourceSection(1, 42)), Core.Columns.OriginalIndex, buffer, destinationIndex, queryOptions), Times.Once, "because the proxy should simply forward those calls to its source"); } }