private void WireUpEvents() { // Model Events _model.TestLoaded += (ea) => InitializeMainMenu(); _model.TestUnloaded += (ea) => InitializeMainMenu(); _model.TestReloaded += (ea) => InitializeMainMenu(); _model.RunStarting += (ea) => InitializeMainMenu(); _model.RunFinished += (ea) => InitializeMainMenu(); // View Events _view.Load += MainForm_Load; _view.FormClosing += MainForm_Closing; _view.NewProjectCommand.Execute += _model.NewProject; _view.OpenProjectCommand.Execute += OnOpenProjectCommand; _view.CloseCommand.Execute += _model.UnloadTests; _view.SaveCommand.Execute += _model.SaveProject; _view.SaveAsCommand.Execute += _model.SaveProject; _view.ReloadTestsCommand.Execute += OnReloadTestsCommand; _view.RecentProjectsMenu.Popup += RecentProjectsMenu_Popup; _view.SelectRuntimeMenu.Popup += SelectRuntimeMenu_Popup; _view.ExitCommand.Execute += () => Application.Exit(); _view.SettingsCommand.Execute += OpenSettingsDialogCommand_Execute; _view.AddinsCommand.Execute += OpenExtensionsDialogCommand_Execute; _view.NUnitHelpCommand.Execute += () => { MessageBox.Show("This will show Help", "Not Yet Implemented"); }; _view.AboutNUnitCommand.Execute += () => { MessageBox.Show("This will show the About Box", "Not Yet Implemented"); }; _view.FormClosing += (s, e) => _model.Dispose(); }
private void WireUpEvents() { // Model Events _model.Events.TestsLoading += NotifyTestsLoading; _model.Events.TestLoaded += (ea) => InitializeMainMenu(); _model.Events.TestUnloaded += (ea) => InitializeMainMenu(); _model.Events.TestsReloading += NotifyTestsReloading; _model.Events.TestReloaded += (ea) => { InitializeMainMenu(); _view.OnTestAssembliesLoaded(); }; _model.Events.TestChanged += (ea) => { if (_model.Services.UserSettings.Engine.ReloadOnChange) { _model.ReloadTests(); } }; _model.Events.RunStarting += (ea) => InitializeMainMenu(); _model.Events.RunFinished += (ea) => InitializeMainMenu(); // View Events _view.Load += MainForm_Load; _view.MainViewClosing += MainForm_Closing; _view.DragDropFiles += MainForm_DragDrop; _view.NewProjectCommand.Execute += ProjectSaveNotYetImplemented; // _model.NewProject; _view.OpenProjectCommand.Execute += OnOpenProjectCommand; _view.CloseCommand.Execute += _model.UnloadTests; _view.SaveCommand.Execute += ProjectSaveNotYetImplemented; // _model.SaveProject; _view.SaveAsCommand.Execute += ProjectSaveNotYetImplemented; // _model.SaveProject; _view.SaveResultsCommand.Execute += () => SaveResults(); _view.ReloadTestsCommand.Execute += _model.ReloadTests; _view.RecentProjectsMenu.Popup += PopulateRecentProjectsMenu; _view.SelectedRuntime.SelectionChanged += SelectedRuntime_SelectionChanged; _view.ProcessModel.SelectionChanged += ProcessModel_SelectionChanged; _view.DomainUsage.SelectionChanged += DomainUsage_SelectionChanged; _view.RunAsX86.CheckedChanged += LoadAsX86_CheckedChanged; _view.ExitCommand.Execute += () => Application.Exit(); _view.SettingsCommand.Execute += OpenSettingsDialogCommand_Execute; _view.AddinsCommand.Execute += OpenExtensionsDialogCommand_Execute; _view.NUnitHelpCommand.Execute += () => { MessageBox.Show("This will show Help", "Not Yet Implemented"); }; _view.AboutNUnitCommand.Execute += () => { MessageBox.Show("This will show the About Box", "Not Yet Implemented"); }; _view.MainViewClosing += () => _model.Dispose(); }
public void ReleaseTestModel() { _model.Dispose(); }
private void WireUpEvents() { // Model Events _model.Events.TestsLoading += (ea) => { var message = ea.TestFilesLoading.Count == 1 ? $"Loading Assembly: {ea.TestFilesLoading[0]}" : $"Loading {ea.TestFilesLoading.Count} Assemblies..."; _view.LongRunningOperation.Display(message); }; _model.Events.TestLoaded += (ea) => { _view.LongRunningOperation.Hide(); InitializeMainMenu(); }; _model.Events.TestUnloaded += (ea) => InitializeMainMenu(); _model.Events.TestsReloading += (ea) => { _view.LongRunningOperation.Display("Reloading Tests..."); }; _model.Events.TestReloaded += (ea) => { _view.LongRunningOperation.Hide(); InitializeMainMenu(); }; _model.Events.TestLoadFailure += (TestLoadFailureEventArgs e) => { _view.LongRunningOperation.Hide(); _view.MessageDisplay.Error(e.Exception.Message); }; _model.Events.TestChanged += (ea) => { if (_model.Settings.Engine.ReloadOnChange) { _model.ReloadTests(); } }; _model.Events.RunStarting += (ea) => InitializeMainMenu(); _model.Events.RunFinished += (ea) => { _view.LongRunningOperation.Hide(); SaveResults(); InitializeMainMenu(); if (_options.Unattended) { _view.Close(); } }; // View Events _view.Load += MainForm_Load; _view.MainViewClosing += MainForm_Closing; _view.DragDropFiles += MainForm_DragDrop; _view.NewProjectCommand.Execute += ProjectSaveNotYetImplemented; // _model.NewProject; _view.OpenProjectCommand.Execute += OnOpenProjectCommand; _view.CloseCommand.Execute += _model.UnloadTests; _view.AddTestFilesCommand.Execute += () => { var filesToAdd = _view.DialogManager.SelectMultipleFiles("Add Test Files", CreateOpenFileFilter()); if (filesToAdd.Count > 0) { var files = new List <string>(_model.TestFiles); files.AddRange(filesToAdd); _model.LoadTests(files); } }; _view.SaveCommand.Execute += ProjectSaveNotYetImplemented; // _model.SaveProject; _view.SaveAsCommand.Execute += ProjectSaveNotYetImplemented; // _model.SaveProject; _view.SaveResultsCommand.Execute += () => SaveResults(); _view.ReloadTestsCommand.Execute += _model.ReloadTests; _view.RecentProjectsMenu.Popup += PopulateRecentProjectsMenu; _view.RunAsX86.CheckedChanged += () => { var key = EnginePackageSettings.RunAsX86; if (_view.RunAsX86.Checked) { OverridePackageSetting(key, true); } else { OverridePackageSetting(key, null); } }; _view.ExitCommand.Execute += () => Application.Exit(); _view.IncreaseFontCommand.Execute += () => { ApplyFont(IncreaseFont(_settings.Gui.Font)); }; _view.DecreaseFontCommand.Execute += () => { ApplyFont(DecreaseFont(_settings.Gui.Font)); }; _view.ChangeFontCommand.Execute += () => { Font currentFont = _settings.Gui.Font; Font newFont = _view.DialogManager.SelectFont(currentFont); if (newFont != _settings.Gui.Font) { ApplyFont(newFont); } }; _view.RestoreFontCommand.Execute += () => { ApplyFont(Form.DefaultFont); }; _view.SettingsCommand.Execute += () => { using (var dialog = new SettingsDialog((Form)_view, _settings)) { dialog.ShowDialog(); } }; _view.ExtensionsCommand.Execute += () => { using (var extensionsDialog = new ExtensionDialog(_model.Services.ExtensionService)) { extensionsDialog.Font = _settings.Gui.Font; extensionsDialog.ShowDialog(); } }; _view.NUnitHelpCommand.Execute += () => { MessageBox.Show("This will show Help", "Not Yet Implemented"); }; _view.AboutNUnitCommand.Execute += () => { MessageBox.Show("This will show the About Box", "Not Yet Implemented"); }; _view.MainViewClosing += () => _model.Dispose(); }
public static int Main(string[] args) { var options = new CommandLineOptions(args); if (options.ShowHelp) { // TODO: We would need to have a custom message box // in order to use a fixed font and display the options // so that the values all line up. MessageDisplay.Info(GetHelpText(options)); return(0); } if (!options.Validate()) { var NL = Environment.NewLine; var sb = new StringBuilder($"Error(s) in command line:{NL}"); foreach (string msg in options.ErrorMessages) { sb.Append($" {msg}{NL}"); } sb.Append($"{NL}{GetHelpText(options)}"); MessageDisplay.Error(sb.ToString()); return(2); } ITestEngine engine = TestEngineActivator.CreateInstance(); log.Info("Instantiating TestModel"); ITestModel model = TestModel.CreateTestModel(engine, options); log.Info("Constructing Form"); TestCentricMainView view = new TestCentricMainView(); log.Info("Constructing presenters"); new ProgressBarPresenter(view.ProgressBarView, model); new StatusBarPresenter(view.StatusBarView, model); new ErrorsAndFailuresPresenter(view.ErrorsAndFailuresView, model); new TestsNotRunPresenter(view.TestsNotRunView, model); new TextOutputPresenter(view.TextOutputView, model); new TreeViewPresenter(view.TreeView, model); new CategoryPresenter(view.CategoryView, model); new TestCentricPresenter(view, model, options); try { log.Info("Starting Gui Application"); Application.Run(view); log.Info("Application Exit"); } catch (Exception ex) { log.Error("Gui Application threw an exception", ex); throw; } finally { log.Info("Exiting TestCentric Runner"); InternalTrace.Close(); model.Dispose(); } return(0); }
private void WireUpEvents() { // Model Events _model.Events.TestsLoading += NotifyTestsLoading; _model.Events.TestLoaded += (ea) => InitializeMainMenu(); _model.Events.TestUnloaded += (ea) => InitializeMainMenu(); _model.Events.TestsReloading += NotifyTestsReloading; _model.Events.TestReloaded += (ea) => { InitializeMainMenu(); _view.OnTestAssembliesLoaded(); }; _model.Events.TestChanged += (ea) => { if (_model.Settings.Engine.ReloadOnChange) { _model.ReloadTests(); } }; _model.Events.RunStarting += (ea) => InitializeMainMenu(); _model.Events.RunFinished += (ea) => InitializeMainMenu(); // View Events _view.Load += MainForm_Load; _view.MainViewClosing += MainForm_Closing; _view.DragDropFiles += MainForm_DragDrop; _view.NewProjectCommand.Execute += ProjectSaveNotYetImplemented; // _model.NewProject; _view.OpenProjectCommand.Execute += OnOpenProjectCommand; _view.CloseCommand.Execute += _model.UnloadTests; _view.AddTestFilesCommand.Execute += () => { var filesToAdd = _view.DialogManager.SelectMultipleFiles("Add Test Files", CreateOpenFileFilter()); if (filesToAdd.Count > 0) { var files = new List <string>(_model.TestFiles); files.AddRange(filesToAdd); _model.LoadTests(files); } }; _view.SaveCommand.Execute += ProjectSaveNotYetImplemented; // _model.SaveProject; _view.SaveAsCommand.Execute += ProjectSaveNotYetImplemented; // _model.SaveProject; _view.SaveResultsCommand.Execute += () => SaveResults(); _view.ReloadTestsCommand.Execute += _model.ReloadTests; _view.RecentProjectsMenu.Popup += PopulateRecentProjectsMenu; _view.SelectedRuntime.SelectionChanged += () => { OverridePackageSetting(EnginePackageSettings.RuntimeFramework, _view.SelectedRuntime.SelectedItem); }; _view.ProcessModel.SelectionChanged += () => { OverridePackageSetting(EnginePackageSettings.ProcessModel, _view.ProcessModel.SelectedItem); }; _view.DomainUsage.SelectionChanged += () => { OverridePackageSetting(EnginePackageSettings.DomainUsage, _view.DomainUsage.SelectedItem); }; _view.RunAsX86.CheckedChanged += () => { var key = EnginePackageSettings.RunAsX86; if (_view.RunAsX86.Checked) { OverridePackageSetting(key, true); } else { OverridePackageSetting(key, null); } }; _view.ExitCommand.Execute += () => Application.Exit(); _view.IncreaseFontCommand.Execute += () => { ApplyFont(IncreaseFont(_settings.Gui.Font)); }; _view.DecreaseFontCommand.Execute += () => { ApplyFont(DecreaseFont(_settings.Gui.Font)); }; _view.ChangeFontCommand.Execute += () => { Font currentFont = _settings.Gui.Font; Font newFont = _view.DialogManager.SelectFont(currentFont); if (newFont != _settings.Gui.Font) { ApplyFont(newFont); } }; _view.RestoreFontCommand.Execute += () => { ApplyFont(Form.DefaultFont); }; _view.SettingsCommand.Execute += () => { using (var dialog = new SettingsDialog((Form)_view, _settings)) { dialog.ShowDialog(); } }; _view.ExtensionsCommand.Execute += () => { using (var extensionsDialog = new ExtensionDialog(_model.Services.ExtensionService)) { extensionsDialog.Font = _settings.Gui.Font; extensionsDialog.ShowDialog(); } }; _view.NUnitHelpCommand.Execute += () => { MessageBox.Show("This will show Help", "Not Yet Implemented"); }; _view.AboutNUnitCommand.Execute += () => { MessageBox.Show("This will show the About Box", "Not Yet Implemented"); }; _view.MainViewClosing += () => _model.Dispose(); }