public void CheckStateAfterRunningTests() { _model.RunTests(TestFilter.Empty); Assert.That(_model.HasTests, "HasTests"); Assert.NotNull(_model.Tests, "Tests"); Assert.False(_model.HasResults, "HasResults"); }
private void MainForm_Load(object sender, System.EventArgs e) { var recentFileService = _model.GetService <IRecentFiles>(); var location = _model.Settings.Gui.MainForm.Location; var size = _model.Settings.Gui.MainForm.Size; if (size == Size.Empty) { size = _view.Size; } if (size.Width < 160) { size.Width = 160; } if (size.Height < 32) { size.Height = 32; } if (!IsVisiblePosition(location, size)) { location = new Point(0, 0); } _view.Location = location; _view.Size = size; // Set to maximized if required if (_model.Settings.Gui.MainForm.Maximized) { _view.WindowState = FormWindowState.Maximized; } // Set the font to use _view.Font = _model.Settings.Gui.MainForm.Font; if (_options.InputFiles.Count > 0) { _model.LoadTests(MakeTestPackage(_options.InputFiles, _options)); } else if (!_options.NoLoad && recentFileService.Entries.Count > 0) { var entry = recentFileService.Entries[0]; if (!string.IsNullOrEmpty(entry) && System.IO.File.Exists(entry)) { _model.LoadTests(MakeTestPackage(entry, _options)); } } if (_options.RunAllTests && _model.IsPackageLoaded) { _model.RunTests(TestFilter.Empty); } }
public void RunTests(TestNode[] tests) { if (_settings.Gui.ReloadOnRun) { _model.ClearResults(); } if (tests != null && tests.Length > 0) { _model.RunTests(new TestSelection(tests)); } }
private void WireUpEvents() { _model.TestLoaded += (ea) => InitializeRunCommands(); _model.TestReloaded += (ea) => InitializeRunCommands(); _model.TestUnloaded += (ea) => InitializeRunCommands(); _model.RunStarting += (ea) => InitializeRunCommands(); _model.RunFinished += (ea) => InitializeRunCommands(); _view.Load += (s, e) => _view.DisplayFormat.SelectedItem = _displayFormat; // Run button and dropdowns _view.RunButton.Execute += () => { // Necessary test because we don't disable the button click if (_model.HasTests && !_model.IsTestRunning) { _model.RunTests(TestFilter.Empty); } }; _view.RunAllCommand.Execute += () => _model.RunTests(TestFilter.Empty); _view.RunSelectedCommand.Execute += () => _model.RunSelectedTest(); _view.RunFailedCommand.Execute += () => _model.RunTests(TestFilter.Empty); // NYI _view.StopRunCommand.Execute += () => _model.CancelTestRun(); // Change of display format _view.DisplayFormat.SelectionChanged += () => { _displayFormat = _view.DisplayFormat.SelectedItem; _model.Settings.Gui.TestTree.DisplayFormat = _displayFormat; // Replace the existing display, which functions as an // adjunct to the presenter by handling certain events. _display = CreateDisplayStrategy(_displayFormat); _view.FormatButton.ToolStripItem.ToolTipText = _display.Description; _display.Reload(); }; }
private void WireUpEvents() { // Model actions _model.TestLoaded += (ea) => Load(ea.Test); _model.TestUnloaded += (ea) => ClearTree(); _model.TestReloaded += (ea) => { ClearTree(); Load(ea.Test); }; _model.TestFinished += (ea) => OnTestFinished(ea.Result); _model.SuiteFinished += (ea) => OnTestFinished(ea.Result); // View actions _view.CollapseAllCommand.Execute += () => _view.CollapseAll(); _view.ExpandAllCommand.Execute += () => _view.ExpandAll(); _view.CollapseToFixturesCommand.Execute += () => CollapseToFixtures(); _view.RunContextCommand.Execute += () => _model.RunTests(_view.Tree.ContextNode.Tag as ITestItem); // Node selected in tree Tree.SelectedNodeChanged += (tn) => _model.SelectedTest = tn.Tag as ITestItem; }
private void WireUpEvents() { // Model actions _model.TestLoaded += (ea) => { _strategy.OnTestLoaded(ea.Test); InitializeRunCommands(); InitializeCategories(ea.Categories); _view.ShowCheckBoxesCommand.Checked = Settings.ShowCheckboxes; }; _model.TestReloaded += (ea) => { _strategy.OnTestLoaded(ea.Test); InitializeRunCommands(); ApplyCategoryFilter(_view.Category.SelectedCategories.Items, _view.Category.ExcludeCommand.Checked); }; _model.TestUnloaded += (ea) => { _strategy.OnTestUnloaded(); InitializeRunCommands(); }; _model.RunStarting += (ea) => InitializeRunCommands(); _model.RunFinished += (ea) => InitializeRunCommands(); _model.TestFinished += (ea) => _strategy.OnTestFinished(ea.Result); _model.SuiteFinished += (ea) => _strategy.OnTestFinished(ea.Result); // View actions - Initial Load _view.Load += (s, e) => SetDefaultDisplayStrategy(); // View context commands _view.Tree.ContextMenu.Popup += () => _view.RunCheckedCommand.Visible = _view.Tree.CheckBoxes && _view.Tree.CheckedNodes.Count > 0; _view.CollapseAllCommand.Execute += () => _view.CollapseAll(); _view.ExpandAllCommand.Execute += () => _view.ExpandAll(); _view.CollapseToFixturesCommand.Execute += () => _strategy.CollapseToFixtures(); _view.ShowCheckBoxesCommand.CheckedChanged += () => { _view.RunSelectedCommand.Enabled = false; _view.Tree.CheckBoxes = _view.CheckAllTestsCommand.Visible = _view.UncheckAllTestsCommand.Visible = _view.CheckFailedTestsCommand.Visible = Settings.ShowCheckboxes = _view.ShowCheckBoxesCommand.Checked; }; _view.CheckAllTestsCommand.Execute += () => { var treeView = _view.Tree?.Control; if (treeView != null) { ToggleNodeCheck(treeView.Nodes, true, true); } }; _view.UncheckAllTestsCommand.Execute += () => { var treeView = _view.Tree?.Control; if (treeView != null) { ToggleNodeCheck(treeView.Nodes, false, true); } }; _view.CheckFailedTestsCommand.Execute += () => { var treeView = _view.Tree?.Control; if (treeView != null) { ToggleNodeCheck(_strategy.GetFailedNodes(), true, true); } }; _view.RunContextCommand.Execute += () => _model.RunTests(_selectedTestItem); _view.RunCheckedCommand.Execute += RunCheckedTests; // Node selected in tree _view.Tree.SelectedNodeChanged += (tn) => { _selectedTestItem = tn.Tag as ITestItem; _view.RunContextCommand.Enabled = (_selectedTestItem as TestNode)?.CanRun() ?? true; _model.NotifySelectedItemChanged(_selectedTestItem); }; // Run button and dropdowns _view.RunButton.Execute += () => _model.RunAllTests(); _view.RunAllCommand.Execute += () => _model.RunAllTests(); _view.RunSelectedCommand.Execute += () => _model.RunTests(_selectedTestItem); _view.RunFailedCommand.Execute += () => RunFailedTest(); _view.StopRunCommand.Execute += () => _model.CancelTestRun(); // Change of display format _view.DisplayFormat.SelectionChanged += () => { SetDisplayStrategy(_view.DisplayFormat.SelectedItem); _strategy.Reload(); ApplyCategoryFilter(_view.Category.SelectedCategories.Items, _view.Category.ExcludeCommand.Checked); }; _view.Category.SelectedCategories.ItemsChanged += (sender, ae) => ApplyCategoryFilter(ae.Value, _view.Category.ExcludeCommand.Checked); _view.Category.ExcludeCommand.CheckedChanged += () => ApplyCategoryFilter(_view.Category.SelectedCategories.Items, _view.Category.ExcludeCommand.Checked); }
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.Events.TestsLoading += (e) => { _view.RunCommand.Enabled = false; }; _model.Events.TestLoaded += (e) => { _view.RunCommand.Enabled = true; _view.CheckPropertiesDialog(); if (e.Test.Children.Count == 1) { _view.LoadTests(e.Test.Children[0]); } else { _view.LoadTests(e.Test); } if (_model.Services.UserSettings.Gui.TestTree.SaveVisualState) { string fileName = VisualState.GetVisualStateFileName(_model.TestFiles[0]); if (File.Exists(fileName) && new FileInfo(fileName).Length > 0) { try { var visualState = VisualState.LoadFrom(fileName); _view.RestoreVisualState(visualState); _model.SelectCategories(visualState.SelectedCategories, visualState.ExcludeCategories); } catch (Exception exception) { var messageDisplay = new MessageDisplay(); messageDisplay.Error($"There was an error loading the Visual State from {fileName}"); } } } }; _model.Events.TestsReloading += (e) => { _view.RunCommand.Enabled = false; }; _model.Events.TestReloaded += (e) => { _view.Reload(e.Test); if (!_settings.Gui.ClearResultsOnReload) { RestoreResults(e.Test); } _view.RunCommand.Enabled = true; }; _model.Events.TestsUnloading += (e) => { _view.RunCommand.Enabled = false; _view.ClosePropertiesDialog(); if (_settings.Gui.TestTree.SaveVisualState) { try { var visualState = _view.GetVisualState(); visualState.SelectedCategories = _model.SelectedCategories; visualState.ExcludeCategories = _model.ExcludeSelectedCategories; visualState.Save(VisualState.GetVisualStateFileName(_model.TestFiles[0])); } catch (Exception ex) { Debug.WriteLine("Unable to save visual state."); Debug.WriteLine(ex); } } _view.Clear(); }; _model.Events.TestUnloaded += (e) => { _view.RunCommand.Enabled = false; }; _model.Events.RunStarting += (e) => { _view.RunCommand.Enabled = false; _view.CheckPropertiesDialog(); }; _model.Events.RunFinished += (e) => { _view.RunCommand.Enabled = true; }; _model.Events.TestFinished += (e) => { _view.SetTestResult(e.Result); }; _model.Events.SuiteFinished += (e) => { _view.SetTestResult(e.Result); }; //_settings.Changed += (s, e) => //{ // if (e.SettingName == "Gui.TestTree.AlternateImageSet") // { // _view.LoadAlternateImages(); // _view.Invalidate(); // } //}; _model.Events.CategorySelectionChanged += (TestEventArgs e) => { TestNodeFilter filter = TestNodeFilter.Empty; if (_model.SelectedCategories.Count > 0) { filter = new CategoryFilter(_model.SelectedCategories); if (_model.ExcludeSelectedCategories) { filter = new NotFilter(filter); } } _view.TreeFilter = filter; }; _view.FileDrop += _model.LoadTests; _view.RunCommand.Execute += () => { if (_settings.Gui.ReloadOnRun) { _model.ClearResults(); } if (_view.ContextNode != null) { _model.RunTests(_view.ContextNode.Test); } else { _model.RunTests(new TestSelection(_view.SelectedTests)); } }; _view.ShowCheckBoxes.CheckedChanged += () => { _settings.Gui.TestTree.ShowCheckBoxes = _view.CheckBoxes = _view.ShowCheckBoxes.Checked; }; _view.ShowFailedAssumptions.CheckedChanged += () => { TestSuiteTreeNode targetNode = _view.ContextNode ?? (TestSuiteTreeNode)_view.SelectedNode; TestSuiteTreeNode theoryNode = targetNode?.GetTheoryNode(); if (theoryNode != null) { theoryNode.ShowFailedAssumptions = _view.ShowFailedAssumptions.Checked; } }; _view.PropertiesCommand.Execute += () => { TestSuiteTreeNode targetNode = _view.ContextNode ?? (TestSuiteTreeNode)_view.SelectedNode; if (targetNode != null) { _view.ShowPropertiesDialog(targetNode); } }; }
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(); }; }
private void WireUpEvents() { _model.Events.TestsLoading += (e) => _view.RunCommand.Enabled = false; _model.Events.TestLoaded += (e) => { _view.RunCommand.Enabled = true; _view.CheckPropertiesDialog(); LoadTests(GetTopDisplayNode(e.Test)); if (_model.Services.UserSettings.Gui.TestTree.SaveVisualState) { string fileName = VisualState.GetVisualStateFileName(_model.TestFiles[0]); if (File.Exists(fileName) && new FileInfo(fileName).Length > 0) { try { var visualState = VisualState.LoadFrom(fileName); visualState.RestoreVisualState(_view, _treeMap); _model.SelectCategories(visualState.SelectedCategories, visualState.ExcludeCategories); } catch (Exception ex) { new MessageDisplay().Error( $"Unable to load visual state from {fileName}{Environment.NewLine}{ex.Message}"); } } } }; _model.Events.TestsReloading += (e) => _view.RunCommand.Enabled = false; _model.Events.TestReloaded += (e) => { ReloadTests(GetTopDisplayNode(e.Test)); if (!_settings.Gui.ClearResultsOnReload) { RestoreResults(e.Test); } _view.RunCommand.Enabled = true; }; _model.Events.TestsUnloading += (e) => { _view.RunCommand.Enabled = false; _view.ClosePropertiesDialog(); if (_settings.Gui.TestTree.SaveVisualState) { try { var visualState = VisualState.LoadFrom(_view); visualState.SelectedCategories = _model.SelectedCategories; visualState.ExcludeCategories = _model.ExcludeSelectedCategories; visualState.Save(VisualState.GetVisualStateFileName(_model.TestFiles[0])); } catch (Exception ex) { Debug.WriteLine("Unable to save visual state."); Debug.WriteLine(ex); } } _view.Clear(); _treeMap.Clear(); }; _model.Events.TestUnloaded += (e) => _view.RunCommand.Enabled = false; _model.Events.RunStarting += (e) => { _view.RunCommand.Enabled = false; _view.CheckPropertiesDialog(); }; _model.Events.RunFinished += (e) => _view.RunCommand.Enabled = true; _model.Events.TestFinished += (e) => SetTestResult(e.Result); _model.Events.SuiteFinished += (e) => SetTestResult(e.Result); _model.Events.CategorySelectionChanged += (TestEventArgs e) => { TestNodeFilter filter = TestNodeFilter.Empty; if (_model.SelectedCategories.Count > 0) { filter = new CategoryFilter(_model.SelectedCategories); if (_model.ExcludeSelectedCategories) { filter = new NotFilter(filter); } } _view.TreeFilter = filter; }; _settings.Changed += (s, e) => { if (e.SettingName == "Gui.TestTree.AlternateImageSet") { _view.AlternateImageSet = _settings.Gui.TestTree.AlternateImageSet; } else if (e.SettingName == "Gui.TestTree.ShowCheckBoxes") { var showCheckBoxes = _settings.Gui.TestTree.ShowCheckBoxes; // When turning off checkboxes with a non-empty tree, the // structure of what is expanded and collapsed is lost. // We save that structure as a VisualState and then restore it. VisualState visualState = !showCheckBoxes && _view.Tree.TopNode != null ? VisualState.LoadFrom(_view) : null; _view.CheckBoxes = showCheckBoxes; if (visualState != null) { visualState.ShowCheckBoxes = showCheckBoxes; visualState.RestoreVisualState(_view, _treeMap); } } }; _view.FileDrop += _model.LoadTests; _view.RunCommand.Execute += () => { if (_settings.Gui.ReloadOnRun) { _model.ClearResults(); } if (_view.ContextNode != null) { _model.RunTests(_view.ContextNode.Test); } else { _model.RunTests(new TestSelection(_view.SelectedTests)); } }; _view.ShowCheckBoxes.CheckedChanged += () => _view.CheckBoxes = _view.ShowCheckBoxes.Checked; _view.ClearAllCheckBoxes.Execute += () => ClearAllCheckBoxes(_view.Tree.TopNode); _view.CheckFailedTests.Execute += () => CheckFailedTests(_view.Tree.TopNode); _view.ShowFailedAssumptions.CheckedChanged += () => { TestSuiteTreeNode targetNode = _view.ContextNode ?? (TestSuiteTreeNode)_view.Tree.SelectedNode; TestSuiteTreeNode theoryNode = targetNode?.GetTheoryNode(); if (theoryNode != null) { theoryNode.ShowFailedAssumptions = _view.ShowFailedAssumptions.Checked; } }; _view.ExpandAllCommand.Execute += () => _view.Tree.ExpandAll(); _view.CollapseAllCommand.Execute += () => _view.Tree.CollapseAll(); _view.HideTestsCommand.Execute += () => HideTestsUnderNode(_model.Tests); _view.PropertiesCommand.Execute += () => { TestSuiteTreeNode targetNode = _view.ContextNode ?? (TestSuiteTreeNode)_view.Tree.SelectedNode; if (targetNode != null) { _view.ShowPropertiesDialog(targetNode); } }; }
private void WireUpEvents() { // Model actions _model.Events.TestLoaded += (ea) => { EnsureNonRunnableFilesAreVisible(ea.Test); Strategy.OnTestLoaded(ea.Test); InitializeRunCommands(); CheckPropertiesDisplay(); CheckXmlDisplay(); }; _model.Events.TestReloaded += (ea) => { EnsureNonRunnableFilesAreVisible(ea.Test); Strategy.OnTestLoaded(ea.Test); InitializeRunCommands(); }; _model.Events.TestUnloaded += (ea) => { Strategy.OnTestUnloaded(); InitializeRunCommands(); }; _model.Events.TestsUnloading += ea => { Strategy.OnTestUnloading(); ClosePropertiesDisplay(); CloseXmlDisplay(); }; _model.Events.RunStarting += (ea) => { InitializeRunCommands(); CheckPropertiesDisplay(); CheckXmlDisplay(); }; _model.Events.RunFinished += (ea) => { InitializeRunCommands(); }; _model.Events.TestFinished += OnTestFinished; _model.Events.SuiteFinished += OnTestFinished; _model.Settings.Changed += (s, e) => { switch (e.SettingName) { case "TestCentric.Gui.TestTree.AlternateImageSet": _view.AlternateImageSet = _treeSettings.AlternateImageSet; break; case "TestCentric.Gui.TestTree.DisplayFormat": case "TestCentric.Gui.TestTree.TestList.GroupBy": case "TestCentric.Gui.TestTree.FixtureList.GroupBy": CreateDisplayStrategy(_treeSettings.DisplayFormat); Strategy.Reload(); break; } }; // 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; _view.TestPropertiesCommand.Execute += () => ShowPropertiesDisplay(); _view.ViewAsXmlCommand.Execute += () => ShowXmlDisplayDialog(); // Node selected in tree _view.Tree.SelectedNodeChanged += (tn) => { _selectedTestItem = tn.Tag as ITestItem; _model.NotifySelectedItemChanged(_selectedTestItem); if (_propertiesDisplay != null) { if (_propertiesDisplay.Pinned) { _propertiesDisplay.Display(tn); } else { ClosePropertiesDisplay(); } } if (_xmlDisplay != null) { if (_xmlDisplay.Pinned) { _xmlDisplay.Display(tn); } else { CloseXmlDisplay(); } } }; }