public void GetModelTypesTest() { PluginFactory.LoadPlugins(pluginPath); var actual = PluginFactory.GetModelTypes(); Assert.IsTrue(actual.Length >= 1); }
public void LoadPluginsTest() { PluginFactory.LoadPlugins(pluginPath); Assert.IsTrue(PluginFactory.Info.Count >= 1, "Expected one info at path " + pluginPath); Assert.IsTrue(PluginFactory.ParserFactories.Count >= 1, "Expected one parser at path " + pluginPath); Assert.IsTrue(PluginFactory.PanelFactories.Count >= 1, "Expected one panel at path " + pluginPath); }
public void FindLogFileParserTest() { PluginFactory.Reset(); PluginFactory.LoadPlugins(pluginPath); IParserFactory lfp = PluginFactory.FindLogFileParser("dummy.csv"); IsTypenameSame(lfp.GetType(), typeof(Sample_Crunch.StandardPanels.CsvParserFactory)); }
public void FindParserTest() { PluginFactory.Reset(); PluginFactory.LoadPlugins(pluginPath); Type factoryType = typeof(Sample_Crunch.StandardPanels.CsvParserFactory); IParserFactory lfp = PluginFactory.FindParser(factoryType.FullName); IsTypenameSame(lfp.GetType(), factoryType); }
public static void AssemblyInitialize(TestContext context) { pluginPath = System.IO.Path.Combine(Environment.CurrentDirectory); // Init plugin reader PluginFactory.LoadPlugins(pluginPath); if (File.Exists(filename)) { File.Delete(filename); } }
public void FindPanelFactoryTest() { PluginFactory.Reset(); PluginFactory.LoadPlugins(pluginPath); Type factoryType = typeof(Sample_Crunch.StandardPanels.TimePlotFactory); var factory = PluginFactory.CreatePanelFactory(factoryType); var model = factory.CreateModel(); IPanelFactory lfp = PluginFactory.FindPanelFactory(model); IsTypenameSame(lfp.GetType(), factoryType); }
public void RegisterModelTypeTest() { PluginFactory.LoadPlugins(pluginPath); var beforeLength = PluginFactory.GetModelTypes().Length; PluginFactory.RegisterModelType(typeof(PluginFactoryTests)); var actual = PluginFactory.GetModelTypes(); CollectionAssert.Contains(actual, typeof(PluginFactoryTests)); Assert.IsTrue(actual.Length == beforeLength + 1); }
public void SaveAndOpenFailures() { PluginFactory.Reset(); PluginFactory.LoadPlugins(pluginPath); Assert.IsFalse(File.Exists(filename), "Project file should not exist"); ProjectData testProj = new ProjectData(); testProj.Files.Add(new FileModel()); testProj.Save(filename); Assert.IsTrue(File.Exists(filename), "No project file written"); ProjectData openedProj = ProjectData.Open(filename); // Should fail since there is no file in filetopic ProjectViewModel projVM = new ProjectViewModel(openedProj); }
public void InvalidPlugin() { StreamWriter sw = File.CreateText(Path.Combine(pluginPath, invalidPlugin)); sw.WriteLine("Not a valid dll!"); sw.Close(); try { List <Exception> execptions = PluginFactory.LoadPlugins(pluginPath); Assert.IsTrue(execptions.Count > 0, "Expect at least one error"); Assert.IsTrue(execptions[0].ToString().Contains(invalidPlugin)); } catch (Exception ex) { Assert.Fail("Unexpected exception" + ex.ToString()); } // Verify that it continued Assert.IsTrue(PluginFactory.ParserFactories.Count >= 1, "Expected one plugin at path " + pluginPath); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { try { var pluginManager = SimpleIoc.Default.GetInstance <ViewModel.PluginManagerViewModel>(); // Create plugin directory if (!Directory.Exists(pluginManager.PluginPath)) { Directory.CreateDirectory(pluginManager.PluginPath); } // Move standard panels dll to plugin directory string standardPanelsTargetPath = Path.Combine(pluginManager.PluginPath, "StandardPanels.dll"); if (!File.Exists(standardPanelsTargetPath)) { string standardPanelsSourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StandardPanels.dll"); File.Copy(standardPanelsSourcePath, standardPanelsTargetPath, true); } // Load plugins from plugin directory List <Exception> errors = PluginFactory.LoadPlugins(pluginManager.PluginPath); foreach (var ex in errors) { await MainViewModel.DialogService.ShowError(ex.InnerException, ex.Message, "Continue", null); } } catch (Exception ex) { await MainViewModel.DialogService.ShowError(ex.Message, "Could not load plugins", "Continue", null); AppTelemetry.ReportError("Loading", ex); } // Add local factories which will not be found because they are not in dll's. PluginFactory.PanelFactories.Add(PluginFactory.CreatePanelFactory(typeof(Factory.MarkerPanelFactory))); PluginFactory.PanelFactories.Add(PluginFactory.CreatePanelFactory(typeof(Factory.ProjectPanelFactory))); MainViewModel.PropertyChanged += Main_PropertyChanged; foreach (var item in PluginFactory.PanelFactories) { // Add if it has no attribute set or if the attribute is set check the visible flag PanelPluginAttribute attr = item.GetType().GetCustomAttribute <PanelPluginAttribute>(false); if (attr == null || attr.Visible) { MainViewModel.Windows.Add(item); } } MainViewModel.NewProjectCommand.Execute(null); if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Length > 0) { string filename = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0].ToString(); try { MainViewModel.Project.AddLogFile(filename); } catch (FileLoadException) { MessageBox.Show("There is no available log file reader that can read that file."); return; } } // If this is first run show news try { bool firstrun = Properties.Settings.Default.FirstRun; if (firstrun) { MainViewModel.ShowWebPageCommand.Execute(@"https://wolkesson.github.io/SampleCrunch/getting-started"); Properties.Settings.Default.AppTelemetry = (MessageBox.Show( "Sample Crunch uses volentary telemetry to track usage and find bugs. Do you approve to send annonumous data?", "Allow telemetry?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes); Properties.Settings.Default.FirstRun = false; Properties.Settings.Default.Save(); } } catch (System.Deployment.Application.InvalidDeploymentException) { // We will end up here if application is not installed, but run locally. } try { // Block App telemetry if user has disapproved it AppTelemetry.DoNotSend = !Properties.Settings.Default.AppTelemetry; if (string.IsNullOrEmpty(Properties.Settings.Default.AppTelemetryUID)) { AppTelemetry.RegisterUser(CultureInfo.InstalledUICulture.EnglishName, MainViewModel.Version); } } catch { } }