Exemplo n.º 1
0
        /// <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;
            }
        }
Exemplo n.º 2
0
        public void TestDispose()
        {
            var analyser = new DataSourceAnalyserProxy(_plugin.Object, AnalyserId.CreateNew(), _scheduler, null, null);

            _actualAnalyser.Setup(x => x.Dispose()).Throws <NullReferenceException>();
            new Action(() => analyser.Dispose()).ShouldNotThrow("because the proxy is supposed to handle failures of its plugin");
            _actualAnalyser.Verify(x => x.Dispose(), Times.Once, "because the proxy should have at least tried to dispose of the inner analyser");
        }
Exemplo n.º 3
0
        public void TestGetConfiguration1()
        {
            var analyser = new DataSourceAnalyserProxy(_plugin.Object, AnalyserId.CreateNew(), _scheduler, null, null);

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

            analyser.Configuration.Should().BeNull();
            _actualAnalyser.Verify(x => x.Configuration, Times.Once);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public void TestRemoveLogFile()
        {
            var analyser = new DataSourceAnalyserProxy(_plugin.Object, AnalyserId.CreateNew(), _scheduler, null, null);

            _actualAnalyser.Setup(x => x.OnLogFileRemoved(It.IsAny <DataSourceId>(), It.IsAny <ILogFile>())).Throws <NullReferenceException>();
            var id      = DataSourceId.CreateNew();
            var logFile = new Mock <ILogFile>().Object;

            new Action(() => analyser.OnLogFileRemoved(id, logFile)).ShouldNotThrow("because the proxy is supposed to handle failures of its plugin");
            _actualAnalyser.Verify(x => x.OnLogFileRemoved(id, logFile), Times.Once, "because the proxy should have at least tried to call RemoveLogFile on the inner analyser");
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public void TestTryGetNonExistentAnalyser()
        {
            var activeAnalysis = new ActiveAnalysis(AnalysisId.CreateNew(), _template, _taskScheduler, _dataSourceAnalyserEngine, TimeSpan.Zero);

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

            var configuration = new Mock <ILogAnalyserConfiguration>().Object;

            activeAnalysis.Add(new AnalyserPluginId("foobar"), configuration);
            activeAnalysis.TryGetAnalyser(AnalyserId.CreateNew(), out var actualAnalyser).Should().BeFalse();
            actualAnalyser.Should().BeNull();
        }
        private IDataSourceAnalyser AddAnalyser()
        {
            var dataSourceAnalyser = new Mock <IDataSourceAnalyser>();
            var analyserId         = AnalyserId.CreateNew();

            dataSourceAnalyser.Setup(x => x.Id).Returns(analyserId);
            var analyser = dataSourceAnalyser.Object;

            _analyser.Setup(x => x.TryGetAnalyser(analyserId, out analyser)).Returns(true);

            return(analyser);
        }
Exemplo n.º 10
0
        /// <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);
        }
Exemplo n.º 11
0
        public void TestClone3()
        {
            var template = new WidgetTemplate
            {
                Id                   = WidgetId.CreateNew(),
                AnalyserId           = AnalyserId.CreateNew(),
                LogAnalyserFactoryId = new LogAnalyserFactoryId("Company.Namespace.MyFactory")
            };
            var clone = template.Clone();

            clone.Should().NotBeNull();
            clone.Should().NotBeSameAs(template);
            clone.Id.Should().Be(template.Id);
            clone.AnalyserId.Should().Be(template.AnalyserId);
            clone.LogAnalyserFactoryId.Should().Be(template.LogAnalyserFactoryId);
        }
Exemplo n.º 12
0
        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>();
        }
Exemplo n.º 13
0
        public void TestSerialize1()
        {
            var template = new WidgetTemplate
            {
                Id            = WidgetId.CreateNew(),
                AnalyserId    = AnalyserId.CreateNew(),
                Title         = "dwankwadjkwad",
                Configuration = new TestConfiguration()
            };

            var actualTemplate = template.Roundtrip(typeof(TestConfiguration));

            actualTemplate.Should().NotBeNull();
            actualTemplate.Id.Should().Be(template.Id);
            actualTemplate.AnalyserId.Should().Be(template.AnalyserId);
            actualTemplate.Title.Should().Be(template.Title);
            actualTemplate.Configuration.Should().NotBeNull();
            actualTemplate.Configuration.Should().BeOfType <TestConfiguration>();
            actualTemplate.Configuration.Should().NotBeSameAs(template.Configuration);
        }
Exemplo n.º 14
0
 public NoAnalyser()
 {
     _id = AnalyserId.CreateNew();
 }
Exemplo n.º 15
0
 public NoAnalyser(LogAnalyserFactoryId factoryId)
 {
     _id        = AnalyserId.CreateNew();
     _factoryId = factoryId;
 }