public void CheckStateAfterReloading() { _model.ReloadTests(); Assert.That(_model.HasTests, "HasTests"); Assert.NotNull(_model.Tests, "Tests"); Assert.False(_model.HasResults, "HasResults"); }
private void RunAllTests() { if (_model.Services.UserSettings.Engine.ReloadOnRun) { _model.ReloadTests(); } _model.RunAllTests(); }
// public void AddToProject() //{ // AddToProject( null ); //} // TODO: Not used? //public void AddToProject( string configName ) //{ // ProjectConfig config = configName == null // ? loader.TestProject.ActiveConfig // : loader.TestProject.Configs[configName]; // OpenFileDialog dlg = new OpenFileDialog(); // dlg.Title = "Add Assemblies To Project"; // dlg.InitialDirectory = config.BasePath; // if ( VisualStudioSupport ) // dlg.Filter = // "Projects & Assemblies(*.csproj,*.vbproj,*.vjsproj, *.vcproj,*.dll,*.exe )|*.csproj;*.vjsproj;*.vbproj;*.vcproj;*.dll;*.exe|" + // "Visual Studio Projects (*.csproj,*.vjsproj,*.vbproj,*.vcproj)|*.csproj;*.vjsproj;*.vbproj;*.vcproj|" + // "C# Projects (*.csproj)|*.csproj|" + // "J# Projects (*.vjsproj)|*.vjsproj|" + // "VB Projects (*.vbproj)|*.vbproj|" + // "C++ Projects (*.vcproj)|*.vcproj|" + // "Assemblies (*.dll,*.exe)|*.dll;*.exe"; // else // dlg.Filter = "Assemblies (*.dll,*.exe)|*.dll;*.exe"; // dlg.FilterIndex = 1; // dlg.FileName = ""; // if ( dlg.ShowDialog() != DialogResult.OK ) // return; // if (PathUtils.IsAssemblyFileType(dlg.FileName)) // { // config.Assemblies.Add(dlg.FileName); // return; // } // else if (VSProject.IsProjectFile(dlg.FileName)) // try // { // VSProject vsProject = new VSProject(dlg.FileName); // MessageBoxButtons buttons; // string msg; // if (configName != null && vsProject.Configs.Contains(configName)) // { // msg = "The project being added may contain multiple configurations;\r\r" + // "Select\tYes to add all configurations found.\r" + // "\tNo to add only the " + configName + " configuration.\r" + // "\tCancel to exit without modifying the project."; // buttons = MessageBoxButtons.YesNoCancel; // } // else // { // msg = "The project being added may contain multiple configurations;\r\r" + // "Select\tOK to add all configurations found.\r" + // "\tCancel to exit without modifying the project."; // buttons = MessageBoxButtons.OKCancel; // } // DialogResult result = Form.MessageDisplay.Ask(msg, buttons); // if (result == DialogResult.Yes || result == DialogResult.OK) // { // loader.TestProject.Add(vsProject); // return; // } // else if (result == DialogResult.No) // { // foreach (string assembly in vsProject.Configs[configName].Assemblies) // config.Assemblies.Add(assembly); // return; // } // } // catch (Exception ex) // { // Form.MessageDisplay.Error("Invalid VS Project", ex); // } // } public void AddTestFile() { OpenFileDialog dlg = CreateOpenFileDialog("Add Test File", true, true); if (dlg.ShowDialog() == DialogResult.OK) { _model.TestFiles.Add(dlg.FileName); _model.ReloadTests(); } }
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 ReloadTests() { _model.ReloadTests(); //NUnitProject project = loader.TestProject; //bool wrapper = project.IsAssemblyWrapper; //string projectPath = project.ProjectPath; //string activeConfigName = project.ActiveConfigName; //// Unload first to avoid message asking about saving //loader.UnloadProject(); //if (wrapper) // OpenProject(projectPath); //else // OpenProject(projectPath, activeConfigName, null); }
private void ChangePackageSetting(string key, object setting) { if (setting == null || setting as string == "DEFAULT") { _model.PackageSettings.Remove(key); } else { _model.PackageSettings[key] = setting; } string message = string.Format("New {0} setting will not take effect until you reload.\r\n\r\n\t\tReload Now?", key); if (_view.MessageDisplay.Ask(message, "Settings Changed") == DialogResult.Yes) { _model.ReloadTests(); } }
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(); }
private void OnReloadTestsCommand() { _model.ReloadTests(); }
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(); }
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.TestChanged += (e) => { if (_settings.Gui.ReloadOnChange) { _model.ReloadTests(); } }; _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); } }; }