Beispiel #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");
        }
Beispiel #2
0
        public void TestSetConfiguration2()
        {
            var analyser = new DataSourceAnalyserProxy(_plugin.Object, AnalyserId.CreateNew(), _scheduler, null, null);

            _actualAnalyser.SetupProperty(x => x.Configuration);

            var config = new TestLogAnalyserConfiguration();

            new Action(() => analyser.Configuration = config).ShouldNotThrow();
            _actualAnalyser.Object.Configuration.Should().Be(config);
        }
Beispiel #3
0
        public void TestSetConfiguration1()
        {
            var analyser = new DataSourceAnalyserProxy(_plugin.Object, AnalyserId.CreateNew(), _scheduler, null, null);

            _actualAnalyser.SetupSet(x => x.Configuration).Throws <NullReferenceException>();

            var config = new TestLogAnalyserConfiguration();

            new Action(() => analyser.Configuration        = config).ShouldNotThrow();
            _actualAnalyser.VerifySet(x => x.Configuration = config, Times.Once);
        }
Beispiel #4
0
        public void TestGetConfiguration2()
        {
            var analyser = new DataSourceAnalyserProxy(_plugin.Object, AnalyserId.CreateNew(), _scheduler, null, null);

            _actualAnalyser.Setup(x => x.Configuration).Throws <NullReferenceException>();

            var config = new TestLogAnalyserConfiguration();

            _actualAnalyser.Setup(x => x.Configuration).Returns(config);
            analyser.Configuration.Should().BeSameAs(config);
        }
Beispiel #5
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");
        }