public ActiveAnalysis( AnalysisId id, AnalysisTemplate template, ITaskScheduler taskScheduler, ILogAnalyserEngine logAnalyserEngine, TimeSpan maximumWaitTime) { if (template == null) { throw new ArgumentNullException(nameof(template)); } if (taskScheduler == null) { throw new ArgumentNullException(nameof(taskScheduler)); } if (logAnalyserEngine == null) { throw new ArgumentNullException(nameof(logAnalyserEngine)); } _id = id; _template = template; _taskScheduler = taskScheduler; _maximumWaitTime = maximumWaitTime; _logFiles = new List <ILogFile>(); _logFile = new LogFileProxy(taskScheduler, maximumWaitTime); _logAnalyserEngine = logAnalyserEngine; _analysers = new Dictionary <DataSourceAnalyser, AnalyserTemplate>(); _syncRoot = new object(); }
protected override ILogFile CreateFromContent(IReadOnlyLogEntries content) { var source = new InMemoryLogFile(content); var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, source); return(proxy); }
public void TestCtor2() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Verify(x => x.AddListener(It.IsAny <ILogFileListener>(), 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; _counter = new LogFileCounter(); _logFile = new LogFileProxy(taskScheduler, maximumWaitTime); _search = new LogFileSearchProxy(taskScheduler, _logFile, maximumWaitTime); _findAllLogFile = new LogFileProxy(taskScheduler, maximumWaitTime); _findAllSearch = new LogFileSearchProxy(taskScheduler, _findAllLogFile, maximumWaitTime); UpdateSearch(); UpdateFindAllSearch(); }
public void TestDispose2() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.Dispose(); _logFile.Verify(l => l.Dispose(), Times.Once); } }
public void TestConstruction() { _logFile.Setup(x => x.Columns).Returns(new[] { LogFileColumns.RawContent }); using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.Columns.Should().Equal(LogFileColumns.RawContent); } }
public void TestInnerLogFile1() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.InnerLogFile = null; _logFile.Verify(x => x.RemoveListener(It.IsAny <ILogFileListener>()), Times.Once); } }
public void TestGetLine() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.GetLine(42); _logFile.Verify(l => l.GetLine(It.Is <int>(x => x == 42)), Times.Once); } }
public void TestProgress2() { var logFile = new LogFileProxy(_scheduler, TimeSpan.Zero); _logFile.Setup(x => x.Progress).Returns(0.5); logFile.InnerLogFile = _logFile.Object; logFile.Progress.Should().Be(0.5); }
public void TestGetColumn3() { var indices = new LogLineIndex[] { 1, 2 }; var buffer = new string[2]; var logFile = new LogFileProxy(_scheduler, TimeSpan.Zero); logFile.GetColumn(indices, LogFileColumns.RawContent, buffer); buffer.Should().OnlyContain(x => ReferenceEquals(x, null)); }
public void TestGetColumn2() { var section = new LogFileSection(42, 100); var buffer = new string[100]; var logFile = new LogFileProxy(_scheduler, TimeSpan.Zero); logFile.GetColumn(section, LogFileColumns.RawContent, buffer); buffer.Should().OnlyContain(x => ReferenceEquals(x, null)); }
public void TestGetLogLineIndexOfOriginalLineIndex2() { using (var proxy = new LogFileProxy(_scheduler, 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 TestStartTimestamp() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.GetValue(LogFileProperties.StartTimestamp)).Returns(new DateTime(2016, 10, 7, 14, 46, 00)); proxy.GetValue(LogFileProperties.StartTimestamp).Should().Be(new DateTime(2016, 10, 7, 14, 46, 00)); _logFile.Setup(x => x.GetValue(LogFileProperties.StartTimestamp)).Returns((DateTime?)null); proxy.GetValue(LogFileProperties.StartTimestamp).Should().NotHaveValue(); } }
public void TestExists() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.None); proxy.GetValue(LogFileProperties.EmptyReason).Should().Be(ErrorFlags.None); _logFile.Setup(x => x.GetValue(LogFileProperties.EmptyReason)).Returns(ErrorFlags.SourceCannotBeAccessed); proxy.GetValue(LogFileProperties.EmptyReason).Should().Be(ErrorFlags.SourceCannotBeAccessed); } }
public void TestFileSize() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.GetValue(LogFileProperties.Size)).Returns(Size.FromBytes(12)); proxy.GetValue(LogFileProperties.Size).Should().Be(Size.FromBytes(12)); _logFile.Setup(x => x.GetValue(LogFileProperties.Size)).Returns(Size.OneMegabyte); proxy.GetValue(LogFileProperties.Size).Should().Be(Size.OneMegabyte); } }
public void TestMaxCharactersPerLine() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.MaxCharactersPerLine).Returns(101); proxy.MaxCharactersPerLine.Should().Be(101); _logFile.Setup(x => x.MaxCharactersPerLine).Returns(42); proxy.MaxCharactersPerLine.Should().Be(42); } }
public void TestCount() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { _logFile.Setup(x => x.Count).Returns(42); proxy.Count.Should().Be(42); _logFile.Setup(x => x.Count).Returns(9001); proxy.Count.Should().Be(9001); } }
public void TestGetSection() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.GetSection(new LogFileSection(42, 101), new LogLine[101]); var expected = new LogFileSection(42, 101); _logFile.Verify(l => l.GetSection(It.Is <LogFileSection>(x => Equals(x, expected)), It.IsAny <LogLine[]>()), Times.Once); } }
public void TestDispose1() { var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero); _scheduler.PeriodicTaskCount.Should().Be(1); proxy.IsDisposed.Should().BeFalse(); new Action(proxy.Dispose).ShouldNotThrow(); proxy.IsDisposed.Should().BeTrue(); _scheduler.PeriodicTaskCount.Should().Be(0); }
public void TestGetLogLineIndexOfOriginalLineIndex1() { using (var proxy = new LogFileProxy(_scheduler, 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 TestGetColumn1() { var section = new LogFileSection(42, 100); var buffer = new string[142]; var logFile = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object); logFile.GetColumn(section, LogFileColumns.RawContent, buffer, 42); _logFile.Verify(x => x.GetColumn(It.Is <LogFileSection>(y => y == section), It.Is <ILogFileColumn <string> >(y => Equals(y, LogFileColumns.RawContent)), It.Is <string[]>(y => ReferenceEquals(y, buffer)), It.Is <int>(y => y == 42)), Times.Once); }
public void TestListen4() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.AddListener(_listener.Object, TimeSpan.Zero, 1000); new Action(() => proxy.OnLogFileModified(new Mock <ILogFile>().Object, new LogFileSection(0, 1))).ShouldNotThrow(); _modifications.Should().Equal(new[] { LogFileSection.Reset }, "because the OnLogFileModified shouldn't have been forwarded since it's from the wrong source"); new Action(() => proxy.OnLogFileModified(null, new LogFileSection(0, 1))).ShouldNotThrow(); _modifications.Should().Equal(new[] { LogFileSection.Reset }, "because the OnLogFileModified shouldn't have been forwarded since it's from the wrong source"); } }
public SingleDataSource(ITaskScheduler taskScheduler, DataSource settings, ILogFile unfilteredLogFile, TimeSpan maximumWaitTime) : base(taskScheduler, settings, maximumWaitTime) { if (unfilteredLogFile == null) { throw new ArgumentNullException(nameof(unfilteredLogFile)); } _originalLogFile = unfilteredLogFile; _unfilteredLogFile = new LogFileProxy(TaskScheduler, MaximumWaitTime); OnSingleLineChanged(); OnUnfilteredLogFileChanged(); }
public SingleDataSource(ILogFileFactory logFileFactory, ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime) : base(taskScheduler, settings, maximumWaitTime) { if (logFileFactory == null) { throw new ArgumentNullException(nameof(logFileFactory)); } _originalLogFile = logFileFactory.Open(settings.File); _unfilteredLogFile = new LogFileProxy(TaskScheduler, MaximumWaitTime); OnSingleLineChanged(); OnUnfilteredLogFileChanged(); }
public void TestListen1() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.AddListener(_listener.Object, TimeSpan.FromSeconds(1), 1000); proxy.OnLogFileModified(_logFile.Object, new LogFileSection(0, 1)); _modifications.Property(x => x.Count).ShouldEventually().Be(2); _modifications.Should().Equal(new[] { LogFileSection.Reset, new LogFileSection(0, 1) }); } }
public void TestEmptyConstruction() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero)) { proxy.InnerLogFile.Should().BeNull(); proxy.MaxCharactersPerLine.Should().Be(0); proxy.GetValue(LogFileProperties.EmptyReason).Should().Be(ErrorFlags.SourceDoesNotExist); proxy.GetValue(LogFileProperties.Size).Should().BeNull(); proxy.GetValue(LogFileProperties.StartTimestamp).Should().NotHaveValue(); proxy.GetValue(LogFileProperties.EndTimestamp).Should().NotHaveValue(); proxy.Count.Should().Be(0); proxy.Columns.Should().Equal(LogFileColumns.Minimum); new Action(() => proxy.GetLine(0)).ShouldThrow <IndexOutOfRangeException>(); new Action(() => proxy.GetSection(new LogFileSection(0, 1))).ShouldThrow <IndexOutOfRangeException>(); } }
public FolderDataSource(ITaskScheduler taskScheduler, ILogFileFactory logFileFactory, IFilesystem filesystem, DataSource settings, TimeSpan maximumWaitTime) { _taskScheduler = taskScheduler; _logFileFactory = logFileFactory; _filesystem = filesystem; _settings = settings; _syncRoot = new object(); _dataSources = new Dictionary <IFileInfo, SingleDataSource>(); _mergedDataSource = new MergedDataSource(taskScheduler, settings, maximumWaitTime); _unfilteredLogFileProxy = new LogFileProxy(taskScheduler, maximumWaitTime); _filteredLogFileProxy = new LogFileProxy(taskScheduler, maximumWaitTime); DoChange(); }
public void TestGetOriginalIndexFrom2() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { var buffer = new LogLineIndex[100]; proxy.GetColumn(new LogFileSection(1, 42), LogFileColumns.OriginalIndex, buffer, 47); _logFile.Verify(x => x.GetColumn(It.Is <LogFileSection>(y => y == new LogFileSection(1, 42)), It.Is <ILogFileColumn <LogLineIndex> >(y => y == LogFileColumns.OriginalIndex), It.Is <LogLineIndex[]>(y => y == buffer), It.Is <int>(y => y == 47)), Times.Once, "because the proxy should simply forward those calls to its source"); } }
public void TestListen1() { using (var proxy = new LogFileProxy(_scheduler, TimeSpan.Zero, _logFile.Object)) { proxy.AddListener(_listener.Object, TimeSpan.Zero, 1000); _listeners.OnRead(500); _listeners.OnRead(600); _scheduler.RunOnce(); _modifications.Should().Equal(new[] { LogFileSection.Reset, new LogFileSection(0, 500), new LogFileSection(500, 100) }); } }
public ActiveAnalysis( AnalysisId id, AnalysisTemplate template, ITaskScheduler taskScheduler, IDataSourceAnalyserEngine analyserEngine, TimeSpan maximumWaitTime) { if (template == null) { throw new ArgumentNullException(nameof(template)); } if (taskScheduler == null) { throw new ArgumentNullException(nameof(taskScheduler)); } if (analyserEngine == null) { throw new ArgumentNullException(nameof(analyserEngine)); } _id = id; _template = template; _taskScheduler = taskScheduler; _maximumWaitTime = maximumWaitTime; _logFiles = new Dictionary <DataSourceId, ILogFile>(); _logFile = new LogFileProxy(taskScheduler, maximumWaitTime); _analyserEngine = analyserEngine; _analysers = new Dictionary <IDataSourceAnalyser, AnalyserTemplate>(); _syncRoot = new object(); foreach (var analysisTemplate in template.Analysers) { // TODO: Solve this conundrum Add((AnalyserTemplate)analysisTemplate); } }