예제 #1
0
        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);
        }
예제 #2
0
        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();
            };
        }
예제 #3
0
        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();
            };
        }
예제 #4
0
        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();
                    }
                }
            };
        }