/// <summary> /// </summary> /// <param name="factoryId"></param> /// <param name="configuration"></param> /// <returns></returns> public IDataSourceAnalyser Add(LogAnalyserFactoryId factoryId, ILogAnalyserConfiguration configuration) { var template = new AnalyserTemplate { Id = AnalyserId.CreateNew(), FactoryId = factoryId, Configuration = configuration }; var analyser = new DataSourceAnalyser(template, _logFile, _logAnalyserEngine); try { analyser.Configuration = configuration; lock (_syncRoot) { _analysers.Add(analyser, template); _template.Add(template); } return(analyser); } catch (Exception) { analyser.Dispose(); throw; } }
public void Setup() { _template = new AnalyserTemplate { Configuration = new TestLogAnalyserConfiguration() }; _logFile = new InMemoryLogFile(); _engine = new Mock <ILogAnalyserEngine>(); _engine.Setup(x => x.CreateAnalysis(It.IsAny <ILogFile>(), It.IsAny <DataSourceAnalysisConfiguration>(), It.IsAny <IDataSourceAnalysisListener>())) .Returns(() => new TestLogAnalyser()); }
public void TestClone2() { var template = new AnalyserTemplate { AnalyserPluginId = new AnalyserPluginId("nöknöökawdawd"), }; var actualTemplate = template.Clone(); actualTemplate.Should().NotBeNull(); actualTemplate.Should().NotBeSameAs(template); actualTemplate.AnalyserPluginId.Should().Be(template.AnalyserPluginId); }
/// <summary> /// </summary> /// <param name="pluginId"></param> /// <param name="configuration"></param> /// <returns></returns> public IDataSourceAnalyser Add(AnalyserPluginId pluginId, ILogAnalyserConfiguration configuration) { var template = new AnalyserTemplate { Id = AnalyserId.CreateNew(), AnalyserPluginId = pluginId, Configuration = configuration }; var analyser = Add(template); _template.Add(template); return(analyser); }
public void TestSerialize2() { var template = new AnalyserTemplate { Configuration = new TestConfiguration() }; // We don't pass the type of the expected sub-types so the configuration // cannot be restored. This can happen when opening a template / snapshot // on an older installation or one that doesn't have a particular plugin. var actualTemplate = template.Roundtrip(); actualTemplate.Should().NotBeNull(); actualTemplate.Configuration.Should().BeNull(); }
public void TestSerialize1() { var template = new AnalyserTemplate { Id = AnalyserId.CreateNew(), AnalyserPluginId = new AnalyserPluginId("lkwdqjklowlkw"), Configuration = new TestConfiguration() }; var actualTemplate = template.Roundtrip(typeof(TestConfiguration)); actualTemplate.Should().NotBeNull(); actualTemplate.Id.Should().Be(template.Id); actualTemplate.AnalyserPluginId.Should().Be(template.AnalyserPluginId); actualTemplate.Configuration.Should().NotBeNull(); actualTemplate.Configuration.Should().BeOfType <TestConfiguration>(); }
/// <inheritdoc /> public IDataSourceAnalyser CreateAnalyser(ILogFile logFile, AnalyserTemplate template) { if (TryGetPlugin(template.AnalyserPluginId, out var plugin)) { // As usual, we don't trust plugins to behave nice and therefore we wrap them in a proxy // which handles all exceptions thrown by the plugin. var analyser = new DataSourceAnalyserProxy(plugin, template.Id, _scheduler, logFile, template.Configuration); Add(analyser); return(analyser); } else { var analyser = new DataSourceAnalyser(template, logFile, _logAnalyserEngine); Add(analyser); return(analyser); } }
public void TestClone1() { var analysisConfiguration = new Mock <ILogAnalyserConfiguration>(); analysisConfiguration.Setup(x => x.Clone()).Returns(new Mock <ILogAnalyserConfiguration>().Object); var template = new AnalyserTemplate { Configuration = analysisConfiguration.Object }; analysisConfiguration.Verify(x => x.Clone(), Times.Never); var clone = template.Clone(); clone.Should().NotBeNull(); clone.Should().NotBeSameAs(template); clone.Configuration.Should().NotBeNull(); clone.Configuration.Should().NotBeSameAs(analysisConfiguration.Object); analysisConfiguration.Verify(x => x.Clone(), Times.Once); }
public DataSourceAnalyser(AnalyserTemplate template, ILogFile logFile, ILogAnalyserEngine logAnalyserEngine) { if (template == null) { throw new ArgumentNullException(nameof(template)); } if (logFile == null) { throw new ArgumentNullException(nameof(logFile)); } if (logAnalyserEngine == null) { throw new ArgumentNullException(nameof(logAnalyserEngine)); } _template = template; _logFile = logFile; _logAnalyserEngine = logAnalyserEngine; }
private IDataSourceAnalyser Add(AnalyserTemplate template) { var analyser = _analyserEngine.CreateAnalyser(_logFile, template); try { lock (_syncRoot) { _analysers.Add(analyser, template); foreach (var pair in _logFiles) { analyser.OnLogFileAdded(pair.Key, pair.Value); } } return(analyser); } catch (Exception) { analyser.Dispose(); throw; } }
public void TestConstruction() { var template = new AnalyserTemplate(); template.AnalyserPluginId.Should().Be(AnalyserPluginId.Empty); }