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"); }
public void Setup() { _taskScheduler = new ManualTaskScheduler(); _logAnalyserEngine = new Mock <ILogAnalyserEngine>(); _logAnalyserEngine.Setup(x => x.CreateAnalysis(It.IsAny <ILogFile>(), It.IsAny <DataSourceAnalysisConfiguration>(), It.IsAny <IDataSourceAnalysisListener>())) .Returns(() => new Mock <IDataSourceAnalysisHandle>().Object); _dataSourceAnalyserEngine = new DataSourceAnalyserEngine(_taskScheduler, _logAnalyserEngine.Object); _template = new AnalysisTemplate(); }
public void TestCreateAnalyser() { var engine = new DataSourceAnalyserEngine(_taskScheduler, _logAnalyserEngine.Object); var logFile = new Mock <ILogFile>(); var analyser = engine.CreateAnalyser(logFile.Object, new AnalyserTemplate { AnalyserPluginId = new AnalyserPluginId("Some Log Analyser Plugin") }); analyser.Should().NotBeNull(); _logAnalyserEngine.Verify(x => x.CreateAnalysis(logFile.Object, It.IsAny <DataSourceAnalysisConfiguration>(), It.IsAny <IDataSourceAnalysisListener>()), Times.Once, "because we have specified a LogAnalyserPluginId and thus the corresponding engine should've been used to perform the analysis"); }
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(); }
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"); }
private static int StartInternal(SingleApplicationHelper.IMutex mutex, string[] args) { InstallExceptionHandlers(); Log.InfoFormat("Starting tailviewer..."); Log.InfoFormat("Commandline arguments: {0}", string.Join(" ", args)); LogEnvironment(); ApplicationSettings settings = ApplicationSettings.Create(); settings.Restore(out var neededPatching); if (neededPatching) { // TODO: Save settings right again to complete the upgrade // (maybe we should preserve an old version) } var actionCenter = new ActionCenter(); using (var taskScheduler = new DefaultTaskScheduler()) using (var serialTaskScheduler = new SerialTaskScheduler()) { var filesystem = new Filesystem(serialTaskScheduler); using (var pluginArchiveLoader = new PluginArchiveLoader(filesystem, Constants.PluginPath)) { var pluginSystem = CreatePluginSystem(pluginArchiveLoader); var fileFormatPlugins = pluginSystem.LoadAllOfType <IFileFormatPlugin>(); var logFileFactory = new PluginLogFileFactory(taskScheduler, fileFormatPlugins); using (var dataSources = new DataSources(logFileFactory, taskScheduler, settings.DataSources)) using (var updater = new AutoUpdater(actionCenter, settings.AutoUpdate)) using (var logAnalyserEngine = new LogAnalyserEngine(taskScheduler, pluginSystem)) using (var dataSourceAnalyserEngine = new DataSourceAnalyserEngine(taskScheduler, logAnalyserEngine, pluginSystem)) using (var analysisStorage = new AnalysisStorage(taskScheduler, filesystem, dataSourceAnalyserEngine, CreateTypeFactory(pluginSystem))) { var arguments = ArgumentParser.TryParse(args); if (arguments.FileToOpen != null) { if (File.Exists(arguments.FileToOpen)) { // Not only do we want to add this file to the list of data sources, // but we also want to select it so the user can view it immediately, regardless // of what was selected previously. var dataSource = dataSources.AddDataSource(arguments.FileToOpen); settings.DataSources.SelectedItem = dataSource.Id; } else { Log.ErrorFormat("File '{0}' does not exist, won't open it!", arguments.FileToOpen); } } if (settings.AutoUpdate.CheckForUpdates) { // Our initial check for updates is not due to a user action // and therefore we don't need to show a notification when the // application is up-to-date. updater.CheckForUpdates(addNotificationWhenUpToDate: false); } var quickFilters = new QuickFilters(settings.QuickFilters); actionCenter.Add(Build.Current); actionCenter.Add(Change.Merge(Changelog.MostRecentPatches)); var application = new App(); var dispatcher = Dispatcher.CurrentDispatcher; var uiDispatcher = new UiDispatcher(dispatcher); dispatcher.UnhandledException += actionCenter.ReportUnhandledException; TaskScheduler.UnobservedTaskException += actionCenter.ReportUnhandledException; var window = new MainWindow(settings) { DataContext = new MainWindowViewModel(settings, dataSources, quickFilters, actionCenter, updater, taskScheduler, analysisStorage, uiDispatcher, pluginSystem) }; settings.MainWindow.RestoreTo(window); window.Show(); mutex.SetListener(window); return(application.Run()); } } } }