private void WireUpEvents() { // Model actions _model.Events.TestLoaded += (ea) => { _strategy.OnTestLoaded(ea.Test); InitializeRunCommands(); }; _model.Events.TestReloaded += (ea) => { _strategy.OnTestLoaded(ea.Test); InitializeRunCommands(); }; _model.Events.TestUnloaded += (ea) => { _strategy.OnTestUnloaded(); InitializeRunCommands(); }; _model.Events.RunStarting += (ea) => InitializeRunCommands(); _model.Events.RunFinished += (ea) => InitializeRunCommands(); _model.Events.TestFinished += (ea) => _strategy.OnTestFinished(ea.Result); _model.Events.SuiteFinished += (ea) => _strategy.OnTestFinished(ea.Result); _model.Services.UserSettings.Changed += (s, e) => { if (e.SettingName == "Gui.TestTree.AlternateImageSet") { _view.AlternateImageSet = Settings.AlternateImageSet; } }; // View actions - Initial Load _view.Load += (s, e) => { SetDefaultDisplayStrategy(); }; // View context commands _view.Tree.ContextMenu.Popup += delegate { bool checkedRunAvailable = _view.Tree.CheckBoxes && _view.Tree.CheckedNodes.Count > 0; _view.RunCheckedCommand.Visible = checkedRunAvailable; _view.DebugCheckedCommand.Visible = checkedRunAvailable; }; _view.CollapseAllCommand.Execute += () => _view.CollapseAll(); _view.ExpandAllCommand.Execute += () => _view.ExpandAll(); _view.CollapseToFixturesCommand.Execute += () => _strategy.CollapseToFixtures(); _view.ShowCheckBoxes.CheckedChanged += () => _view.Tree.CheckBoxes = _view.ShowCheckBoxes.Checked;; _view.RunContextCommand.Execute += () => { if (_selectedTestItem != null) { _model.RunTests(_selectedTestItem); } }; _view.RunCheckedCommand.Execute += RunCheckedTests; _view.DebugContextCommand.Execute += () => { if (_selectedTestItem != null) { _model.DebugTests(_selectedTestItem); } }; _view.DebugCheckedCommand.Execute += DebugCheckedTests; // Node selected in tree _view.Tree.SelectedNodeChanged += (tn) => { _selectedTestItem = tn.Tag as ITestItem; _model.NotifySelectedItemChanged(_selectedTestItem); }; // Run button and dropdowns _view.RunButton.Execute += () => { // Necessary test because we don't disable the button click if (_model.HasTests && !_model.IsTestRunning) { RunAllTests(); } }; _view.RunAllCommand.Execute += () => RunAllTests(); _view.RunSelectedCommand.Execute += () => RunTests(_selectedTestItem); _view.RunFailedCommand.Execute += () => RunAllTests(); // RunFailed NYI _view.StopRunCommand.Execute += () => _model.CancelTestRun(); // Debug button and dropdowns _view.DebugButton.Execute += () => { // Necessary test because we don't disable the button click if (_model.HasTests && !_model.IsTestRunning) { _model.DebugAllTests(); } }; _view.DebugAllCommand.Execute += () => _model.DebugAllTests(); _view.DebugSelectedCommand.Execute += () => _model.DebugTests(_selectedTestItem); _view.DebugFailedCommand.Execute += () => _model.DebugAllTests(); // NYI // Change of display format _view.DisplayFormat.SelectionChanged += () => { SetDisplayStrategy(_view.DisplayFormat.SelectedItem); _strategy.Reload(); }; }
private void WireUpEvents() { // Model actions _model.Events.TestLoaded += (ea) => { _strategy.OnTestLoaded(ea.Test); InitializeRunCommands(); }; _model.Events.TestReloaded += (ea) => { _strategy.OnTestLoaded(ea.Test); InitializeRunCommands(); }; _model.Events.TestUnloaded += (ea) => { _strategy.OnTestUnloaded(); InitializeRunCommands(); }; _model.Events.RunStarting += (ea) => InitializeRunCommands(); _model.Events.RunFinished += (ea) => InitializeRunCommands(); _model.Events.TestFinished += (ea) => _strategy.OnTestFinished(ea.Result); _model.Events.SuiteFinished += (ea) => _strategy.OnTestFinished(ea.Result); _model.Settings.Changed += (s, e) => { if (e.SettingName == "Gui.TestTree.AlternateImageSet") { _view.AlternateImageSet = Settings.AlternateImageSet; } }; // View actions - Initial Load _view.Load += (s, e) => { SetDefaultDisplayStrategy(); }; // View context commands // Test for null is a hack that allows us to avoid // a problem under Linux creating a ContextMenuStrip // when no display is present. if (_view.Tree.ContextMenuStrip != null) { _view.Tree.ContextMenuStrip.Opening += (s, e) => InitializeContextMenu(); } _view.CollapseAllCommand.Execute += () => _view.CollapseAll(); _view.ExpandAllCommand.Execute += () => _view.ExpandAll(); _view.CollapseToFixturesCommand.Execute += () => _strategy.CollapseToFixtures(); _view.ShowCheckBoxes.CheckedChanged += () => { _view.RunCheckedCommand.Visible = _view.DebugCheckedCommand.Visible = _view.Tree.CheckBoxes = _view.ShowCheckBoxes.Checked; }; _view.RunContextCommand.Execute += () => { if (_selectedTestItem != null) { _model.RunTests(_selectedTestItem); } }; _view.RunCheckedCommand.Execute += RunCheckedTests; _view.DebugContextCommand.Execute += () => { if (_selectedTestItem != null) { _model.DebugTests(_selectedTestItem); } }; _view.DebugCheckedCommand.Execute += DebugCheckedTests; // Node selected in tree _view.Tree.SelectedNodeChanged += (tn) => { _selectedTestItem = tn.Tag as ITestItem; _model.NotifySelectedItemChanged(_selectedTestItem); }; // Run button and dropdowns _view.RunButton.Execute += () => { // Necessary test because we don't disable the button click if (_model.HasTests && !_model.IsTestRunning) { RunAllTests(); } }; _view.RunAllCommand.Execute += () => RunAllTests(); _view.RunSelectedCommand.Execute += () => RunTests(_selectedTestItem); _view.RunFailedCommand.Execute += () => RunAllTests(); // RunFailed NYI _view.StopRunCommand.Execute += () => _model.CancelTestRun(true); _view.TestParametersCommand.Execute += () => { using (var dlg = new TestParametersDialog()) { dlg.Font = _model.Settings.Gui.Font; dlg.StartPosition = FormStartPosition.CenterParent; if (_model.PackageOverrides.ContainsKey("TestParametersDictionary")) { var testParms = _model.PackageOverrides["TestParametersDictionary"] as IDictionary <string, string>; foreach (string key in testParms.Keys) { dlg.Parameters.Add(key, testParms[key]); } } if (dlg.ShowDialog(_view as IWin32Window) == DialogResult.OK) { ChangePackageSettingAndReload("TestParametersDictionary", dlg.Parameters); } } }; // Debug button and dropdowns _view.DebugButton.Execute += () => { // Necessary test because we don't disable the button click if (_model.HasTests && !_model.IsTestRunning) { _model.DebugAllTests(); } }; _view.DebugAllCommand.Execute += () => _model.DebugAllTests(); _view.DebugSelectedCommand.Execute += () => _model.DebugTests(_selectedTestItem); _view.DebugFailedCommand.Execute += () => _model.DebugAllTests(); // NYI // Change of display format _view.DisplayFormat.SelectionChanged += () => { SetDisplayStrategy(_view.DisplayFormat.SelectedItem); _strategy.Reload(); }; }