示例#1
0
        public void TestRemoveAnalyser()
        {
            var id     = new AnalyserPluginId("Some Data Source Analyser Plugin");
            var plugin = new Mock <IDataSourceAnalyserPlugin>();

            plugin.Setup(x => x.Id).Returns(id);
            var pluginAnalyser = new Mock <IDataSourceAnalyser>();

            plugin.Setup(x => x.Create(It.IsAny <AnalyserId>(),
                                       It.IsAny <ITaskScheduler>(),
                                       It.IsAny <ILogFile>(),
                                       It.IsAny <ILogAnalyserConfiguration>()))
            .Returns(pluginAnalyser.Object);
            var engine        = new DataSourceAnalyserEngine(_taskScheduler, _logAnalyserEngine.Object, CreatePluginLoader(plugin.Object));
            var logFile       = new Mock <ILogFile>();
            var configuration = new TestLogAnalyserConfiguration();
            var analyser      = engine.CreateAnalyser(logFile.Object, new AnalyserTemplate
            {
                AnalyserPluginId = id,
                Configuration    = configuration
            });

            analyser.Should().NotBeNull();

            pluginAnalyser.Verify(x => x.Dispose(), Times.Never, "because the analyser is still in used and thus may not have been disposed of yet");
            engine.RemoveAnalyser(analyser);
            pluginAnalyser.Verify(x => x.Dispose(), Times.Once, "because now that the analyser has been removed, it should've been disposed of");
        }
示例#2
0
            public bool TryReadAttribute(string name, out AnalyserPluginId value)
            {
                string tmp;

                if (!TryReadAttribute(name, out tmp))
                {
                    value = default(AnalyserPluginId);
                    return(false);
                }

                value = new AnalyserPluginId(tmp);
                return(true);
            }
示例#3
0
        public void TestAddRemoveCustomAnalyzer1()
        {
            var pluginLoader = new PluginRegistry();
            var id           = new AnalyserPluginId("stuff");
            var plugin       = new Mock <IDataSourceAnalyserPlugin>();

            plugin.Setup(x => x.Id).Returns(id);
            pluginLoader.Register(plugin.Object);
            _dataSourceAnalyserEngine = new DataSourceAnalyserEngine(_taskScheduler, _logAnalyserEngine.Object, pluginLoader);
            var activeAnalysis = new ActiveAnalysis(AnalysisId.CreateNew(), _template, _taskScheduler, _dataSourceAnalyserEngine, TimeSpan.Zero);

            _template.Analysers.Should().BeEmpty();

            var analyser = activeAnalysis.Add(id, null);

            _template.Analysers.Should().HaveCount(1);

            activeAnalysis.Remove(analyser);
            _template.Analysers.Should().BeEmpty();
        }
示例#4
0
        public void TestCreateCustomDataSourceAnalyser()
        {
            var id     = new AnalyserPluginId("Some Data Source Analyser Plugin");
            var plugin = new Mock <IDataSourceAnalyserPlugin>();

            plugin.Setup(x => x.Id).Returns(id);
            var engine        = new DataSourceAnalyserEngine(_taskScheduler, _logAnalyserEngine.Object, CreatePluginLoader(plugin.Object));
            var logFile       = new Mock <ILogFile>();
            var configuration = new TestLogAnalyserConfiguration();
            var analyser      = engine.CreateAnalyser(logFile.Object, new AnalyserTemplate
            {
                AnalyserPluginId = id,
                Configuration    = configuration
            });

            analyser.Should().NotBeNull();

            _logAnalyserEngine.Verify(x => x.CreateAnalysis(It.IsAny <ILogFile>(), It.IsAny <DataSourceAnalysisConfiguration>(), It.IsAny <IDataSourceAnalysisListener>()),
                                      Times.Never, "because we have specified a DataSourceAnalyserPluginId and thus the corresponding plugin should've been used to create the data source analyser");
            plugin.Verify(x => x.Create(It.IsAny <AnalyserId>(), It.IsAny <ITaskScheduler>(), logFile.Object, configuration),
                          Times.Once, "because we have specified a DataSourceAnalyserPluginId and thus its plugin should've been loaded and used to create the analyser");
        }
示例#5
0
 /// <inheritdoc />
 public void WriteAttribute(string name, AnalyserPluginId value)
 {
     WriteAttribute(name, value.ToString());
 }
示例#6
0
 /// <inheritdoc />
 public bool TryReadAttribute(string name, out AnalyserPluginId value)
 {
     return(_documentReader.TryReadAttribute(name, out value));
 }