Index: Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs =================================================================== diff -u -rb9851915fb250e14a7608ae243fe94b6ab8d8abf -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision b9851915fb250e14a7608ae243fe94b6ab8d8abf) +++ Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -23,6 +23,7 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; +using Core.Common.Base.IO; using Core.Common.Base.Service; using Core.Common.Gui.Forms; using Core.Common.Gui.Forms.ProgressDialog; @@ -122,21 +123,49 @@ private void ImportItemsUsingDialog(ImportInfo importInfo, object target) { + FileDialogResult filePathSelection = GetFilePath(importInfo.FileFilter); + + if (filePathSelection.FileSelected && importInfo.VerifyUpdates(target)) + { + RunImportActivity(importInfo.CreateFileImporter(target, filePathSelection.FileName), importInfo.Name); + } + } + + private void RunImportActivity(IFileImporter importer, string importName) + { + log.Info(Resources.GuiImportHandler_ImportItemsUsingDialog_Start_importing_data); + + var activity = new FileImportActivity(importer, importName); + ActivityProgressDialogRunner.Run(dialogParent, activity); + } + + private static FileDialogResult GetFilePath(string fileFilter) + { using (var dialog = new OpenFileDialog { - Multiselect = true, - Filter = importInfo.FileFilter, + Multiselect = false, + Filter = fileFilter, Title = Resources.OpenFileDialog_Title }) { - if (dialog.ShowDialog(dialogParent) == DialogResult.OK) - { - log.Info(Resources.GuiImportHandler_ImportItemsUsingDialog_Start_importing_data); + DialogResult result = dialog.ShowDialog(); + bool fileSelected = result.Equals(DialogResult.OK); - FileImportActivity[] importActivitiesToRun = dialog.FileNames.Select(f => new FileImportActivity(importInfo.CreateFileImporter(target, f), importInfo.Name)).ToArray(); - ActivityProgressDialogRunner.Run(dialogParent, importActivitiesToRun); - } + return new FileDialogResult(fileSelected, dialog.FileName); } } + + private class FileDialogResult + { + public FileDialogResult(bool fileSelected, string fileName) + { + FileSelected = fileSelected; + FileName = fileName; + } + + public string FileName { get; } + + public bool FileSelected { get; } + } } } \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,157 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Base.IO; +using Core.Common.Base.Service; +using Core.Common.Gui.Forms; +using Core.Common.Gui.Forms.ProgressDialog; +using Core.Common.Gui.Plugin; +using Core.Common.Gui.Properties; +using Core.Common.Utils.Reflection; +using log4net; + +namespace Core.Common.Gui.Commands +{ + /// + /// Class responsible for handling import workflow with user interaction. + /// + public class GuiUpdateHandler : IUpdateCommandHandler + { + private static readonly ILog log = LogManager.GetLogger(typeof(GuiImportHandler)); + + private readonly IWin32Window dialogParent; + private readonly IEnumerable updateInfos; + private readonly DialogBasedInquiryHelper inquiryHelper; + + /// + /// Initializes a new instance of the class. + /// + /// The parent window to show dialogs on top. + /// An enumeration of . + public GuiUpdateHandler(IWin32Window dialogParent, IEnumerable updateInfos) + { + if (dialogParent == null) + { + throw new ArgumentNullException(nameof(dialogParent)); + } + if (updateInfos == null) + { + throw new ArgumentNullException(nameof(updateInfos)); + } + this.dialogParent = dialogParent; + this.updateInfos = updateInfos; + inquiryHelper = new DialogBasedInquiryHelper(dialogParent); + } + + public bool CanUpdateOn(object target) + { + return GetSupportedUpdateInfos(target).Any(); + } + + public void UpdateOn(object target) + { + UpdateInfo updateInfo = GetSupportedUpdaterUsingDialog(target); + if (updateInfo != null) + { + UpdateItemsUsingDialog(updateInfo, target); + } + } + + private IEnumerable GetSupportedUpdateInfos(object target) + { + if (target == null) + { + return Enumerable.Empty(); + } + + var targetType = target.GetType(); + + return updateInfos.Where(info => (info.DataType == targetType || targetType.Implements(info.DataType)) && info.IsEnabled(target)); + } + + private UpdateInfo GetSupportedUpdaterUsingDialog(object target) + { + UpdateInfo[] supportedUpdateInfo = GetSupportedUpdateInfos(target).ToArray(); + if (supportedUpdateInfo.Length == 0) + { + MessageBox.Show(dialogParent, + Resources.GuiUpdateHandler_GetSupportedUpdaterForTargetType_No_updater_available_for_this_item, + Resources.GuiUpdateHandler_GetSupportedUpdaterForTargetType_Error); + log.ErrorFormat(Resources.GuiUpdateHandler_GetSupportedUpdaterForTargetType_No_updater_available_for_this_item_0_, + target); + return null; + } + + if (supportedUpdateInfo.Length == 1) + { + return supportedUpdateInfo[0]; + } + + using (var selectUpdaterDialog = new SelectItemDialog(dialogParent, Resources.GuiUpdateHandler_GetSupportedUpdaterUsingDialog_Select_updater)) + { + foreach (UpdateInfo updateInfo in supportedUpdateInfo) + { + string category = string.IsNullOrEmpty(updateInfo.Category) ? + Resources.GuiUpdateHandler_GetSupportedUpdaterForTargetType_Data_Update : + updateInfo.Category; + Image itemImage = updateInfo.Image ?? Resources.brick; + + selectUpdaterDialog.AddItemType(updateInfo.Name, category, itemImage, null); + } + + if (selectUpdaterDialog.ShowDialog() == DialogResult.OK) + { + return supportedUpdateInfo.First(i => i.Name == selectUpdaterDialog.SelectedItemTypeName); + } + } + + return null; + } + + private void UpdateItemsUsingDialog(UpdateInfo updateInfo, object target) + { + string filePath = updateInfo.CurrentPath(target); + if (!File.Exists(filePath)) + { + FileResult fileDialogResult = inquiryHelper.GetSourceFileLocation(updateInfo.FileFilter); + filePath = fileDialogResult.FilePath; + } + if (filePath != null && updateInfo.VerifyUpdates(target)) + { + RunUpdateActivity(updateInfo.CreateFileImporter(target, filePath), updateInfo.Name); + } + } + + private void RunUpdateActivity(IFileImporter importer, string importName) + { + log.Info(Resources.GuiImportHandler_ImportItemsUsingDialog_Start_importing_data); + + var activity = new FileImportActivity(importer, importName); + ActivityProgressDialogRunner.Run(dialogParent, activity); + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Commands/IUpdateCommandHandler.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Commands/IUpdateCommandHandler.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Commands/IUpdateCommandHandler.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,49 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Core.Common.Gui.Commands +{ + /// + /// Interface declaring commands/methods related to importing data. + /// + public interface IUpdateCommandHandler + { + /// + /// Indicates if there are updaters for the given target object. + /// + /// The target object to check updater availability for. + /// true if there are updaters available, false otherwise. + bool CanUpdateOn(object target); + + /// + /// Perform the update workflow by the following steps: + /// + /// If multiple updaters are available for the target object, ask the user + /// which updater to use; + /// Check whether the path to the already imported file exists; + /// If not, ask the user which file to use to update from; + /// Import from the user specified file and update the target object. + /// + /// + /// The data object to update. + void UpdateOn(object target); + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs =================================================================== diff -u -r0d3788fdf7aa5b050974f69bcea4f8e71a096d58 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision 0d3788fdf7aa5b050974f69bcea4f8e71a096d58) +++ Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -42,32 +42,34 @@ /// Creates a new instance of . /// /// The from which to obtain - /// information to render and bind actions to the items of the . If null, - /// this builder will not render items which require this type of information. + /// information to render and bind actions to the items of the . If null, + /// this builder will not render items which require this type of information. /// The from which to obtain - /// information to render and bind actions to the items of the . If null, - /// this builder will not render items which require this type of information. + /// information to render and bind actions to the items of the . If null, + /// this builder will not render items which require this type of information. /// The from which to obtain - /// information to render and bind actions to the items of the . If null, - /// this builder will not render items which require this type of information. + /// information to render and bind actions to the items of the . If null, + /// this builder will not render items which require this type of information. + /// /// The from which to obtain information to render - /// and bind actions to the items of the . If null, this builder will not - /// render items which require this type of information. + /// and bind actions to the items of the . If null, this builder will not + /// render items which require this type of information. /// The data object for which to create a . /// The to use while executing the actions. /// Thrown when any input argument is null. public ContextMenuBuilder(IApplicationFeatureCommands featureCommandHandler, IImportCommandHandler importCommandHandler, IExportCommandHandler exportCommandHandler, - IViewCommands viewCommands, - object dataValue, + IUpdateCommandHandler updateCommandHandler, + IViewCommands viewCommands, object dataValue, TreeViewControl treeViewControl) { try { guiItemsFactory = new GuiContextMenuItemFactory(featureCommandHandler, importCommandHandler, exportCommandHandler, + updateCommandHandler, viewCommands, dataValue); @@ -128,6 +130,12 @@ return this; } + public IContextMenuBuilder AddUpdateItem() + { + AddItem(guiItemsFactory.CreateUpdateItem()); + return this; + } + public IContextMenuBuilder AddCustomImportItem(string text, string toolTip, Image image) { AddItem(guiItemsFactory.CreateCustomImportItem(text, toolTip, image)); Index: Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs =================================================================== diff -u -r589249bddd12bd66da39205d408ff6e907220116 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision 589249bddd12bd66da39205d408ff6e907220116) +++ Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -35,6 +35,7 @@ private readonly IApplicationFeatureCommands applicationFeatureCommandHandler; private readonly IImportCommandHandler importCommandHandler; private readonly IExportCommandHandler exportCommandHandler; + private readonly IUpdateCommandHandler updateCommandHandler; private readonly IViewCommands viewCommands; private readonly object dataObject; @@ -54,6 +55,7 @@ public GuiContextMenuItemFactory(IApplicationFeatureCommands applicationFeatureCommandHandler, IImportCommandHandler importCommandHandler, IExportCommandHandler exportCommandHandler, + IUpdateCommandHandler updateCommandHandler, IViewCommands viewCommandsHandler, object dataObject) { @@ -72,6 +74,11 @@ throw new ArgumentNullException(nameof(exportCommandHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_export_handler); } + if (updateCommandHandler == null) + { + throw new ArgumentNullException(nameof(updateCommandHandler), + Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_update_handler); + } if (viewCommandsHandler == null) { throw new ArgumentNullException(nameof(viewCommandsHandler), @@ -85,6 +92,7 @@ this.applicationFeatureCommandHandler = applicationFeatureCommandHandler; this.importCommandHandler = importCommandHandler; this.exportCommandHandler = exportCommandHandler; + this.updateCommandHandler = updateCommandHandler; viewCommands = viewCommandsHandler; this.dataObject = dataObject; } @@ -138,6 +146,25 @@ } /// + /// Creates a which is bound to the action of updating + /// the data of the given . + /// + /// The created . + public ToolStripItem CreateUpdateItem() + { + bool canImport = updateCommandHandler.CanUpdateOn(dataObject); + var newItem = new ToolStripMenuItem(Resources.Update) + { + ToolTipText = Resources.Update_ToolTip, + Image = Resources.RefreshIcon, + Enabled = canImport + }; + newItem.Click += (s, e) => updateCommandHandler.UpdateOn(dataObject); + + return newItem; + } + + /// /// Creates a which is bound to the action of importing /// to the data of the given . /// Index: Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilder.cs =================================================================== diff -u -r0d3788fdf7aa5b050974f69bcea4f8e71a096d58 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilder.cs (.../IContextMenuBuilder.cs) (revision 0d3788fdf7aa5b050974f69bcea4f8e71a096d58) +++ Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilder.cs (.../IContextMenuBuilder.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -79,6 +79,12 @@ IContextMenuBuilder AddImportItem(); /// + /// Adds an item to the , which updates the data of the . + /// + /// The itself. + IContextMenuBuilder AddUpdateItem(); + + /// /// Adds an item to the , which imports to the data of the . /// /// The text of the import item. Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj =================================================================== diff -u -r0ce9c8ee8f2918efdef2f85992c00c7da3f5b5eb -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 0ce9c8ee8f2918efdef2f85992c00c7da3f5b5eb) +++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 45440093089496f59ed420e772136756c229e30b) @@ -107,10 +107,12 @@ + + @@ -120,6 +122,9 @@ + + + @@ -135,11 +140,13 @@ + + @@ -362,6 +369,7 @@ + Index: Core/Common/src/Core.Common.Gui/DialogBasedInquiryHelper.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/DialogBasedInquiryHelper.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/DialogBasedInquiryHelper.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,91 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Windows.Forms; +using Core.Common.Gui.Properties; +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; + +namespace Core.Common.Gui +{ + /// + /// Class which inquires the user for application inputs based on dialogs. + /// + public class DialogBasedInquiryHelper : IInquiryHelper + { + private readonly IWin32Window dialogParent; + + public DialogBasedInquiryHelper(IWin32Window dialogParent) + { + this.dialogParent = dialogParent; + } + + public FileResult GetSourceFileLocation() + { + return GetSourceFileLocation(new ExpectedFile()); + } + + public FileResult GetSourceFileLocation(ExpectedFile filter) + { + string filePath = null; + using (OpenFileDialog dialog = new OpenFileDialog + { + Multiselect = false, + Title = Resources.OpenFileDialog_Title, + Filter = filter.Filter + }) + { + DialogResult result = dialog.ShowDialog(); + if (result == DialogResult.OK) + { + filePath = dialog.FileName; + } + } + return new FileResult(filePath); + } + + public FileResult GetTargetFileLocation() + { + string filePath = null; + using (SaveFileDialog dialog = new SaveFileDialog + { + Title = Resources.SaveFileDialog_Title + }) + { + DialogResult result = dialog.ShowDialog(); + if (result == DialogResult.OK) + { + filePath = dialog.FileName; + } + } + return new FileResult(filePath); + } + + public bool InquireContinuation(string query) + { + DialogResult dialog = MessageBox.Show( + dialogParent, + query, + CoreCommonBaseResources.Confirm, + MessageBoxButtons.OKCancel); + return dialog == DialogResult.OK; + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/ExpectedFile.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/ExpectedFile.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/ExpectedFile.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,76 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Core.Common.Gui +{ + /// + /// Class which produces a file filter based on the expected extension. If no specific + /// extension is expected, then a filter for all file types will be produced. + /// + public class ExpectedFile { + + private readonly string extension = "*"; + private readonly string description = "Alle bestanden"; + + /// + /// Creates a new instance of which filters + /// for all files. + /// + public ExpectedFile() + { + } + + /// + /// Creates a new instance of which filters files based on + /// a specified file extension. + /// + /// The extension of the files to filter on. + public ExpectedFile(string typeExtension) + { + extension = typeExtension; + description = $"{typeExtension.ToUpperInvariant()}-bestanden"; + } + + /// + /// Creates a new instance of which filters files based on + /// a specified file extension. + /// + /// The extension of the files to filter on. + /// The description of files which have + /// as their extension. + public ExpectedFile(string typeExtension, string typeDescription) + { + description = typeDescription; + extension = typeExtension; + } + + /// + /// Gets a filter string for the . + /// + public string Filter + { + get + { + return $"{description} (*.{extension})|*.{extension}"; + } + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/FileResult.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/FileResult.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/FileResult.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,55 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Core.Common.Gui +{ + /// + /// The result of a file inquiry operation. + /// + public class FileResult + { + /// + /// Creates a new . + /// + /// The path to a file. + public FileResult(string filePath) + { + FilePath = filePath; + } + + /// + /// Gets the path to the file. + /// + public string FilePath { get; } + + /// + /// Returns true if the contains a + /// , false othwerise. + /// + public bool HasFilePath + { + get + { + return FilePath != null; + } + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Forms/SelectItemDialog.cs =================================================================== diff -u -r49c5da81f49a23dd6e66526d264a08bf510e6963 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/Forms/SelectItemDialog.cs (.../SelectItemDialog.cs) (revision 49c5da81f49a23dd6e66526d264a08bf510e6963) +++ Core/Common/src/Core.Common.Gui/Forms/SelectItemDialog.cs (.../SelectItemDialog.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -63,7 +63,7 @@ { get { - return SelectedItem != null ? SelectedItem.Tag : null; + return SelectedItem?.Tag; } } @@ -74,7 +74,7 @@ { get { - return SelectedItem != null ? SelectedItem.Name : null; + return SelectedItem?.Name; } } Index: Core/Common/src/Core.Common.Gui/GuiCore.cs =================================================================== diff -u -rb2b9fdf365e70928a05c57966eeed30d9050e528 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision b2b9fdf365e70928a05c57966eeed30d9050e528) +++ Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -120,6 +120,7 @@ storageCommandHandler = new StorageCommandHandler(projectStore, projectFactory, this, MainWindow); importCommandHandler = new GuiImportHandler(MainWindow, Plugins.SelectMany(p => p.GetImportInfos())); exportCommandHandler = new GuiExportHandler(MainWindow, Plugins.SelectMany(p => p.GetExportInfos())); + updateCommandHandler = new GuiUpdateHandler(MainWindow, Plugins.SelectMany(p => p.GetUpdateInfos())); WindowsApplication.EnableVisualStyles(); ViewPropertyEditor.ViewCommands = ViewCommands; @@ -203,7 +204,8 @@ return new ContextMenuBuilder(applicationFeatureCommands, importCommandHandler, - exportCommandHandler, + exportCommandHandler, + updateCommandHandler, ViewCommands, value, treeViewControl); @@ -691,6 +693,7 @@ private readonly ViewCommandHandler viewCommandHandler; private readonly GuiImportHandler importCommandHandler; private readonly GuiExportHandler exportCommandHandler; + private readonly GuiUpdateHandler updateCommandHandler; private readonly IStorageCommands storageCommandHandler; public IApplicationFeatureCommands ApplicationCommands Index: Core/Common/src/Core.Common.Gui/IInquiryHelper.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/IInquiryHelper.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/IInquiryHelper.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,60 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Core.Common.Gui +{ + /// + /// Specifies the interface for classes that can be used to inquire information from + /// the user. + /// + public interface IInquiryHelper + { + /// + /// Returns a containing a path to an existing file + /// if the user did not cancel the inquiry. + /// + /// A new . + FileResult GetSourceFileLocation(); + + /// + /// Returns a containing a path to an existing file + /// if the user did not cancel the inquiry. + /// + /// A filter to which the path in the returned + /// complies. + /// A new . + FileResult GetSourceFileLocation(ExpectedFile filter); + + /// + /// Returns a containing a path to a (non-existing) file + /// if the user did not cancel the inquiry. + /// + /// A containing a path to a (non-existing) file. + FileResult GetTargetFileLocation(); + + /// + /// Gets the confirmation of a user. + /// + /// The query to which the user needs to answer. + /// true if the user confirmed, false otherwise. + bool InquireContinuation(string query); + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Plugin/ImportInfo.cs =================================================================== diff -u -r587f6330c5876eb326e8bea5e82a3650866cc475 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/Plugin/ImportInfo.cs (.../ImportInfo.cs) (revision 587f6330c5876eb326e8bea5e82a3650866cc475) +++ Core/Common/src/Core.Common.Gui/Plugin/ImportInfo.cs (.../ImportInfo.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -45,6 +45,8 @@ /// public Func CreateFileImporter { get; set; } + public Func VerifyUpdates { get; set; } + /// /// Gets or sets the method used to determine whether or not the import routine should be enabled. Function arguments: /// @@ -115,6 +117,8 @@ /// public Func IsEnabled { get; set; } + public Func VerifyUpdates { get; set; } + /// /// Gets or sets the name of the import information. /// @@ -149,10 +153,9 @@ return new ImportInfo { DataType = importInfo.DataType, - CreateFileImporter = (data, path) => importInfo.CreateFileImporter != null ? - importInfo.CreateFileImporter((TData) data, path) : - null, + CreateFileImporter = (data, path) => importInfo.CreateFileImporter?.Invoke((TData) data, path), IsEnabled = data => importInfo.IsEnabled == null || importInfo.IsEnabled((TData) data), + VerifyUpdates = data => importInfo.VerifyUpdates == null || importInfo.VerifyUpdates((TData) data), Name = importInfo.Name, Category = importInfo.Category, Image = importInfo.Image, Index: Core/Common/src/Core.Common.Gui/Plugin/PluginBase.cs =================================================================== diff -u -rf08fd5cc1482a6c706bdb04d46b6482d489b7c5b -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/Plugin/PluginBase.cs (.../PluginBase.cs) (revision f08fd5cc1482a6c706bdb04d46b6482d489b7c5b) +++ Core/Common/src/Core.Common.Gui/Plugin/PluginBase.cs (.../PluginBase.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -67,6 +67,14 @@ } /// + /// Returns all instances provided by this plug-in. + /// + public virtual IEnumerable GetUpdateInfos() + { + yield break; + } + + /// /// Returns all instances provided by this plug-in. /// public virtual IEnumerable GetExportInfos() Index: Core/Common/src/Core.Common.Gui/Plugin/UpdateInfo.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Plugin/UpdateInfo.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Plugin/UpdateInfo.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,159 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using Core.Common.Base.IO; + +namespace Core.Common.Gui.Plugin +{ + /// + /// Information for creating an importer for a particular data object. + /// + public class UpdateInfo + { + /// + /// Gets or sets the data type associated with this import info. + /// + public Type DataType { get; set; } + + /// + /// Gets or sets the method used to create a . Function arguments: + /// + /// The data to import. + /// The file to import data from. + /// out - The created importer. + /// + /// + public Func CreateFileImporter { get; set; } + + /// + /// Gets or sets the method used to determine whether or not the import routine should be enabled. Function arguments: + /// + /// The data to import. + /// out - true if the import should be enabled, false otherwise. + /// + /// + public Func IsEnabled { get; set; } + public Func VerifyUpdates { get; set; } + public Func CurrentPath { get; set; } + + /// + /// Gets or sets the name of the import information. + /// + public string Name { get; set; } + + /// + /// Gets or sets the category of the import information. + /// + public string Category { get; set; } + + /// + /// Gets or sets the image of the import information. + /// + public Image Image { get; set; } + + /// + /// Gets or sets the file filter of the import information. + /// + public ExpectedFile FileFilter { get; set; } + } + + /// + /// Information for creating an importer for a particular data object. + /// + /// The data type associated with this import info. + public class UpdateInfo + { + /// + /// Gets the data type associated with this import info. + /// + public Type DataType + { + get + { + return typeof(TData); + } + } + + /// + /// Gets or sets the method used to create a . Function arguments: + /// + /// The data to import. + /// The path to the file to import from. + /// out - The created importer. + /// + /// + public Func CreateFileImporter { get; set; } + + /// + /// Gets or sets the method used to determine whether or not the import routine should be enabled. Function arguments: + /// + /// The data to import. + /// out - true if the import should be enabled, false otherwise. + /// + /// + public Func IsEnabled { get; set; } + public Func VerifyUpdates { get; set; } + public Func CurrentPath { get; set; } + + /// + /// Gets or sets the name of the import information. + /// + public string Name { get; set; } + + /// + /// Gets or sets the category of the import information. + /// + public string Category { get; set; } + + /// + /// Gets or sets the image of the import information. + /// + public Image Image { get; set; } + + /// + /// Gets or sets the file filter of the import information. + /// + public ExpectedFile FileFilter { get; set; } + + /// + /// Performs an implicit conversion from to . + /// + /// The import information to convert. + /// The result of the conversion. + public static implicit operator UpdateInfo(UpdateInfo importInfo) + { + return new UpdateInfo + { + DataType = importInfo.DataType, + CreateFileImporter = (data, path) => importInfo.CreateFileImporter?.Invoke((TData) data, path), + IsEnabled = data => importInfo.IsEnabled == null || importInfo.IsEnabled((TData) data), + VerifyUpdates = data => importInfo.VerifyUpdates == null || importInfo.VerifyUpdates((TData) data), + CurrentPath = data => importInfo.CurrentPath?.Invoke((TData) data), + Name = importInfo.Name, + Category = importInfo.Category, + Image = importInfo.Image, + FileFilter = importInfo.FileFilter + }; + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs =================================================================== diff -u -ra666c7d6aa029937de402e181f119c72707bfb73 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a666c7d6aa029937de402e181f119c72707bfb73) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -720,6 +720,16 @@ } /// + /// Looks up a localized string similar to Kan geen 'IUpdateCommandHandler'-afhankelijk element in het contextmenu creëren zonder een 'IUpdateCommandHandler'.. + /// + public static string GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_update_handler { + get { + return ResourceManager.GetString("GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_update_ha" + + "ndler", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Kan geen 'IViewCommands'-afhankelijk element in het contextmenu creëren zonder een 'IViewCommands'.. /// public static string GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_view_commands { @@ -888,6 +898,53 @@ } /// + /// Looks up a localized string similar to Bijwerken gegevens. + /// + public static string GuiUpdateHandler_GetSupportedUpdaterForTargetType_Data_Update { + get { + return ResourceManager.GetString("GuiUpdateHandler_GetSupportedUpdaterForTargetType_Data_Update", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fout. + /// + public static string GuiUpdateHandler_GetSupportedUpdaterForTargetType_Error { + get { + return ResourceManager.GetString("GuiUpdateHandler_GetSupportedUpdaterForTargetType_Error", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Geen enkele 'Updater' is beschikbaar voor dit element.. + /// + public static string GuiUpdateHandler_GetSupportedUpdaterForTargetType_No_updater_available_for_this_item { + get { + return ResourceManager.GetString("GuiUpdateHandler_GetSupportedUpdaterForTargetType_No_updater_available_for_this_i" + + "tem", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Geen enkele 'Updater' is beschikbaar voor dit element ({0}).. + /// + public static string GuiUpdateHandler_GetSupportedUpdaterForTargetType_No_updater_available_for_this_item_0_ { + get { + return ResourceManager.GetString("GuiUpdateHandler_GetSupportedUpdaterForTargetType_No_updater_available_for_this_i" + + "tem_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kies wat u wilt bijwerken. + /// + public static string GuiUpdateHandler_GetSupportedUpdaterUsingDialog_Select_updater { + get { + return ResourceManager.GetString("GuiUpdateHandler_GetSupportedUpdaterUsingDialog_Select_updater", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap icon_clear_all_messages { @@ -1106,6 +1163,16 @@ } /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap RefreshIcon { + get { + object obj = ResourceManager.GetObject("RefreshIcon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// /// Looks up a localized string similar to &Hernoemen. /// public static string Rename { @@ -1479,5 +1546,23 @@ return ResourceManager.GetString("StorageCommandHandler_Saving_project_failed", resourceCulture); } } + + /// + /// Looks up a localized string similar to &Bijwerken.... + /// + public static string Update { + get { + return ResourceManager.GetString("Update", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Werk de geïmporteerde gegevens bij met nieuwe gegevens vanuit een bestand.. + /// + public static string Update_ToolTip { + get { + return ResourceManager.GetString("Update_ToolTip", resourceCulture); + } + } } } Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx =================================================================== diff -u -ra666c7d6aa029937de402e181f119c72707bfb73 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision a666c7d6aa029937de402e181f119c72707bfb73) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 45440093089496f59ed420e772136756c229e30b) @@ -181,6 +181,9 @@ Geen enkele 'Importer' is beschikbaar voor dit element ({0}). + + Geen enkele 'Updater' is beschikbaar voor dit element ({0}). + Geen documentvenster geregistreerd voor: {0}. @@ -274,6 +277,9 @@ Geen enkele 'Importer' is beschikbaar voor dit element. + + Geen enkele 'Updater' is beschikbaar voor dit element. + Afsluiten @@ -292,6 +298,9 @@ Importeren gegevens + + Bijwerken gegevens + ..\Resources\icon_clear_all_messages.PNG;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -412,6 +421,9 @@ Fout + + Fout + Faalkansruimte [1/jaar] @@ -505,6 +517,9 @@ Kan geen 'IExportCommandHandler'-afhankelijk element in het contextmenu creëren zonder een 'IExportCommandHandler'. + + Kan geen 'IUpdateCommandHandler'-afhankelijk element in het contextmenu creëren zonder een 'IUpdateCommandHandler'. + Kan geen 'IViewCommands'-afhankelijk element in het contextmenu creëren zonder een 'IViewCommands'. @@ -553,6 +568,9 @@ Kies wat u wilt importeren + + Kies wat u wilt bijwerken + Opslaan als @@ -568,4 +586,13 @@ Er zijn geen onderliggende elementen om te verwijderen. + + &Bijwerken... + + + Werk de geïmporteerde gegevens bij met nieuwe gegevens vanuit een bestand. + + + ..\resources\table_refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Resources/table_refresh.png =================================================================== diff -u Binary files differ Index: Core/Common/test/Core.Common.Controls.Test/Dialogs/DialogBaseTest.cs =================================================================== diff -u -r24da3aa72ccc0776599628c9f971081694048d9a -r45440093089496f59ed420e772136756c229e30b --- Core/Common/test/Core.Common.Controls.Test/Dialogs/DialogBaseTest.cs (.../DialogBaseTest.cs) (revision 24da3aa72ccc0776599628c9f971081694048d9a) +++ Core/Common/test/Core.Common.Controls.Test/Dialogs/DialogBaseTest.cs (.../DialogBaseTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -150,7 +150,8 @@ { // Setup var mocks = new MockRepository(); - var window = mocks.Stub(); + var window = mocks.StrictMock(); + window.Expect(w => w.Handle).Repeat.AtLeastOnce().Return(default(IntPtr)); mocks.ReplayAll(); Icon icon = IconStub(); @@ -180,7 +181,8 @@ { // Setup var mocks = new MockRepository(); - var window = mocks.Stub(); + var window = mocks.StrictMock(); + window.Expect(w => w.Handle).Repeat.AtLeastOnce().Return(default(IntPtr)); mocks.ReplayAll(); Icon icon = IconStub(); Index: Core/Common/test/Core.Common.Gui.Test/Commands/GuiUpdateHandlerTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Commands/GuiUpdateHandlerTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Commands/GuiUpdateHandlerTest.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,252 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Gui.Commands; +using Core.Common.Gui.Forms.MainWindow; +using Core.Common.Gui.Plugin; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Common.Gui.Test.Commands +{ + [TestFixture] + public class GuiUpdateHandlerTest : NUnitFormTest + { + [Test] + public void Constructor_WithoutDialogParent_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new GuiUpdateHandler(null, Enumerable.Empty()); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("dialogParent", paramName); + } + + [Test] + public void Constructor_WithoutUpdateInfos_ThrowsArgumentNullException() + { + // Setup + var mockRepository = new MockRepository(); + var mainWindow = mockRepository.Stub(); + mockRepository.ReplayAll(); + + // Call + TestDelegate test = () => new GuiUpdateHandler(mainWindow, null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("updateInfos", paramName); + mockRepository.VerifyAll(); + } + + [Test] + public void UpdateOn_NoUpdaterAvailable_GivesMessageBox() + { + // Setup + var mockRepository = new MockRepository(); + var mainWindow = mockRepository.Stub(); + mockRepository.ReplayAll(); + + string messageBoxTitle = null, messageBoxText = null; + DialogBoxHandler = (name, wnd) => + { + var messageBox = new MessageBoxTester(wnd); + + messageBoxText = messageBox.Text; + messageBoxTitle = messageBox.Title; + + messageBox.ClickOk(); + }; + + var importHandler = new GuiUpdateHandler(mainWindow, Enumerable.Empty()); + + // Call + importHandler.UpdateOn(typeof(long)); + + // Assert + Assert.AreEqual("Fout", messageBoxTitle); + Assert.AreEqual("Geen enkele 'Updater' is beschikbaar voor dit element.", messageBoxText); + mockRepository.VerifyAll(); + } + + [Test] + public void UpdateOn_NoSupportedUpdateInfoAvailable_GivesMessageBox() + { + // Setup + var mockRepository = new MockRepository(); + var mainWindow = mockRepository.Stub(); + mockRepository.ReplayAll(); + + string messageBoxTitle = null, messageBoxText = null; + DialogBoxHandler = (name, wnd) => + { + var messageBox = new MessageBoxTester(wnd); + + messageBoxText = messageBox.Text; + messageBoxTitle = messageBox.Title; + + messageBox.ClickOk(); + }; + + var importHandler = new GuiUpdateHandler(mainWindow, new UpdateInfo[] + { + new UpdateInfo() + }); + + // Call + importHandler.UpdateOn(typeof(long)); + + // Assert + Assert.AreEqual("Fout", messageBoxTitle); + Assert.AreEqual("Geen enkele 'Updater' is beschikbaar voor dit element.", messageBoxText); + mockRepository.VerifyAll(); + } + + [Test] + public void CanUpdateOn_HasNoFileUpdatersForTarget_ReturnFalse() + { + // Setup + var mocks = new MockRepository(); + var dialogParent = mocks.Stub(); + mocks.ReplayAll(); + + var commandHandler = new GuiUpdateHandler(dialogParent, Enumerable.Empty()); + + // Call + bool isImportPossible = commandHandler.CanUpdateOn(new object()); + + // Assert + Assert.IsFalse(isImportPossible); + mocks.VerifyAll(); + } + + [Test] + public void CanUpdateOn_HasOneUpdateInfoForTarget_ReturnTrue() + { + // Setup + var target = new object(); + + var mocks = new MockRepository(); + var dialogParent = mocks.Stub(); + mocks.ReplayAll(); + + var commandHandler = new GuiUpdateHandler(dialogParent, new UpdateInfo[] + { + new UpdateInfo() + }); + + // Call + bool isImportPossible = commandHandler.CanUpdateOn(target); + + // Assert + Assert.IsTrue(isImportPossible); + mocks.VerifyAll(); + } + + [Test] + public void CanUpdateOn_HasOneUpdateInfoForTargetThatIsNotEnabledForTarget_ReturnFalse() + { + // Setup + var target = new object(); + var mocks = new MockRepository(); + var dialogParent = mocks.Stub(); + mocks.ReplayAll(); + + var commandHandler = new GuiUpdateHandler(dialogParent, new UpdateInfo[] + { + new UpdateInfo + { + IsEnabled = data => false + } + }); + + // Call + bool isImportPossible = commandHandler.CanUpdateOn(target); + + // Assert + Assert.IsFalse(isImportPossible); + mocks.VerifyAll(); + } + + [Test] + public void CanUpdateOn_HasMultipleUpdateInfosForTargetWhereAtLeastOneEnabledForTargetItem_ReturnTrue() + { + // Setup + var target = new object(); + var mocks = new MockRepository(); + var dialogParent = mocks.Stub(); + mocks.ReplayAll(); + + var commandHandler = new GuiUpdateHandler(dialogParent, new UpdateInfo[] + { + new UpdateInfo + { + IsEnabled = data => false + }, + new UpdateInfo + { + IsEnabled = data => true + } + }); + + // Call + bool isImportPossible = commandHandler.CanUpdateOn(target); + + // Assert + Assert.IsTrue(isImportPossible); + mocks.VerifyAll(); + } + + [Test] + public void CanUpdateOn_HasMultipleUpdateInfosForTargetThatCannotBeUsedForImporting_ReturnFalse() + { + // Setup + var target = new object(); + var mocks = new MockRepository(); + var dialogParent = mocks.Stub(); + mocks.ReplayAll(); + + var commandHandler = new GuiUpdateHandler(dialogParent, new UpdateInfo[] + { + new UpdateInfo + { + IsEnabled = data => false + }, + new UpdateInfo + { + IsEnabled = data => false + } + }); + + // Call + bool isImportPossible = commandHandler.CanUpdateOn(target); + + // Assert + Assert.IsFalse(isImportPossible); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs =================================================================== diff -u -r0d3788fdf7aa5b050974f69bcea4f8e71a096d58 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision 0d3788fdf7aa5b050974f69bcea4f8e71a096d58) +++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -48,6 +48,7 @@ // Setup var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -57,6 +58,7 @@ TestDelegate test = () => new ContextMenuBuilder(null, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); @@ -73,6 +75,7 @@ { // Setup var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var applicationFeatureCommandsMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -83,6 +86,7 @@ TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMock, null, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); @@ -99,6 +103,7 @@ { // Setup var importCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var applicationFeatureCommandsMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -109,6 +114,7 @@ TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, null, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); @@ -121,12 +127,41 @@ } [Test] + public void Constructor_NoUpdateCommandHandler_ThrowsContextMenuBuilderException() + { + // Setup + var importCommandHandlerMock = mocks.StrictMock(); + var exportCommandHandlerMock = mocks.StrictMock(); + var applicationFeatureCommandsMock = mocks.StrictMock(); + var viewCommandsMock = mocks.StrictMock(); + mocks.ReplayAll(); + + using (var treeViewControl = new TreeViewControl()) + { + // Call + TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMock, + importCommandHandlerMock, + exportCommandHandlerMock, + null, + viewCommandsMock, + new object(), + treeViewControl); + + // Assert + string message = Assert.Throws(test).Message; + Assert.AreEqual(Resources.ContextMenuBuilder_ContextMenuBuilder_Cannot_create_instances_of_factories, message); + } + mocks.VerifyAll(); + } + + [Test] public void Constructor_NoViewCommands_ThrowsContextMenuBuilderException() { // Setup var applicationFeatureCommandsMockMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); mocks.ReplayAll(); using (var treeViewControl = new TreeViewControl()) @@ -135,6 +170,7 @@ TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMockMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, null, new object(), treeViewControl); @@ -153,6 +189,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -162,6 +199,7 @@ TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, null, treeViewControl); @@ -180,12 +218,14 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); // Call TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), null); @@ -202,6 +242,7 @@ var applicationFeatureCommandsMockMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -211,6 +252,7 @@ TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMockMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); @@ -228,6 +270,7 @@ var applicationFeatureCommandsMockMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -236,6 +279,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMockMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); @@ -260,20 +304,19 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var treeNodeInfoMock = mocks.StrictMock>(); + mocks.ReplayAll(); treeNodeInfoMock.CanRename = (data, parentData) => data == dataObject; - treeViewControl.RegisterTreeNodeInfo(treeNodeInfoMock); - treeViewControl.Data = dataObject; - mocks.ReplayAll(); - var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, dataObject, treeViewControl); @@ -302,9 +345,11 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var treeNodeInfoMock = mocks.StrictMock>(); var parentTreeNodeInfoMock = mocks.StrictMock>(); + mocks.ReplayAll(); treeNodeInfoMock.CanRemove = (nd, pnd) => nd == nodeData && pnd == parentData; parentTreeNodeInfoMock.ChildNodeObjects = nd => new object[] @@ -317,11 +362,10 @@ treeViewControl.Data = parentData; - mocks.ReplayAll(); - var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData, treeViewControl); @@ -349,6 +393,7 @@ var applicationFeatureCommandsMock = mocks.Stub(); var importCommandHandlerMock = mocks.Stub(); var exportCommandHandlerMock = mocks.Stub(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.Stub(); var treeViewControlMock = mocks.StrictMock(); treeViewControlMock.Expect(tvc => tvc.CanRemoveChildNodesOfData(dataObject)).Return(hasChildren).Repeat.AtLeastOnce(); @@ -358,6 +403,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, dataObject, treeViewControlMock); @@ -387,6 +433,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var treeViewControlMock = mocks.StrictMock(); @@ -397,6 +444,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, dataObject, treeViewControlMock); @@ -423,6 +471,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var treeViewControlMock = mocks.StrictMock(); @@ -433,6 +482,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, dataObject, treeViewControlMock); @@ -460,6 +510,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); viewCommandsMock.Expect(ch => ch.CanOpenViewFor(nodeData)).Return(hasViewForNodeData); @@ -470,6 +521,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData, treeViewControl); @@ -497,6 +549,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); exportCommandHandlerMock.Expect(ch => ch.CanExportFrom(nodeData)).Return(hasExportersForNodeData); @@ -507,6 +560,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData, treeViewControl); @@ -534,6 +588,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); importCommandHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(hasImportersForNodeData); @@ -544,6 +599,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData, treeViewControl); @@ -563,6 +619,45 @@ [Test] [TestCase(true)] [TestCase(false)] + public void AddUpdateItem_WhenBuild_ItemAddedToContextMenu(bool hasUpdatesForNodeData) + { + // Setup + var nodeData = new object(); + + var applicationFeatureCommandsMock = mocks.StrictMock(); + var importCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); + var exportCommandHandlerMock = mocks.StrictMock(); + var viewCommandsMock = mocks.StrictMock(); + updateCommandHandlerMock.Expect(ch => ch.CanUpdateOn(nodeData)).Return(hasUpdatesForNodeData); + + mocks.ReplayAll(); + + using (var treeViewControl = new TreeViewControl()) + { + var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, + importCommandHandlerMock, + exportCommandHandlerMock, + updateCommandHandlerMock, + viewCommandsMock, + nodeData, + treeViewControl); + + // Call + ContextMenuStrip result = builder.AddUpdateItem().Build(); + + // Assert + Assert.IsInstanceOf(result); + Assert.AreEqual(1, result.Items.Count); + + TestHelper.AssertContextMenuStripContainsItem(result, 0, Resources.Update, Resources.Update_ToolTip, Resources.RefreshIcon, hasUpdatesForNodeData); + } + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] public void AddCustomImportItem_WhenBuild_ItemAddedToContenxtMenu(bool hasImportersForNodeData) { // Setup @@ -575,6 +670,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); importCommandHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(hasImportersForNodeData); @@ -585,6 +681,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData, treeViewControl); @@ -612,6 +709,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); applicationFeatureCommandsMock.Expect(ch => ch.CanShowPropertiesFor(nodeData)).Return(hasPropertiesForNodeData); @@ -622,6 +720,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData, treeViewControl); @@ -645,13 +744,15 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); using (var treeViewControl = new TreeViewControl()) { var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); @@ -676,6 +777,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -684,6 +786,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); @@ -707,6 +810,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -715,14 +819,15 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); var someItem = new StrictContextMenuItem(null, null, null, null); // Call - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { builder.AddSeparator(); } @@ -746,6 +851,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -754,6 +860,7 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); @@ -764,7 +871,7 @@ builder.AddCustomItem(someItem); // Call - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { builder.AddSeparator(); } @@ -789,6 +896,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -797,14 +905,15 @@ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object(), treeViewControl); builder.AddCustomItem(new StrictContextMenuItem(null, null, null, null)); // Call - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { builder.AddSeparator(); } Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs =================================================================== diff -u -r0324c332753d36bb804a804b9757ef1cd336435f -r45440093089496f59ed420e772136756c229e30b --- Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs (.../GuiContextMenuItemFactoryTest.cs) (revision 0324c332753d36bb804a804b9757ef1cd336435f) +++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs (.../GuiContextMenuItemFactoryTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -21,6 +21,7 @@ using System; using System.Drawing; +using System.Windows.Forms; using Core.Common.Gui.Commands; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Properties; @@ -47,18 +48,20 @@ // Setup var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); // Call TestDelegate test = () => new GuiContextMenuItemFactory(null, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object()); // Assert - var message = Assert.Throws(test).Message; + string message = Assert.Throws(test).Message; StringAssert.StartsWith(Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_gui, message); StringAssert.EndsWith("applicationFeatureCommandHandler", message); @@ -71,18 +74,20 @@ // Setup var applicationFeatureCommandHandler = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); // Call TestDelegate test = () => new GuiContextMenuItemFactory(applicationFeatureCommandHandler, null, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, null); // Assert - var message = Assert.Throws(test).Message; + string message = Assert.Throws(test).Message; StringAssert.StartsWith(Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_import_handler, message); StringAssert.EndsWith("importCommandHandler", message); @@ -95,42 +100,72 @@ // Setup var applicationFeatureCommandHandler = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); // Call TestDelegate test = () => new GuiContextMenuItemFactory(applicationFeatureCommandHandler, importCommandHandlerMock, null, + updateCommandHandlerMock, viewCommandsMock, null); // Assert - var message = Assert.Throws(test).Message; + string message = Assert.Throws(test).Message; StringAssert.StartsWith(Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_export_handler, message); StringAssert.EndsWith("exportCommandHandler", message); mocks.VerifyAll(); } [Test] + public void Constructor_WithoutUpdateCommandHandler_ThrowsArgumentNullException() + { + // Setup + var applicationFeatureCommandHandler = mocks.StrictMock(); + var importCommandHandlerMock = mocks.StrictMock(); + var exportCommandHandlerMock = mocks.StrictMock(); + var viewCommandsMock = mocks.StrictMock(); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => new GuiContextMenuItemFactory(applicationFeatureCommandHandler, + importCommandHandlerMock, + exportCommandHandlerMock, + null, + viewCommandsMock, + null); + + // Assert + string message = Assert.Throws(test).Message; + StringAssert.StartsWith(Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_update_handler, message); + StringAssert.EndsWith("updateCommandHandler", message); + + mocks.VerifyAll(); + } + + [Test] public void Constructor_WithoutViewCommandsHandler_ThrowsArgumentNullException() { // Setup var applicationFeatureCommandHandler = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); mocks.ReplayAll(); // Call TestDelegate test = () => new GuiContextMenuItemFactory(applicationFeatureCommandHandler, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, null, null); // Assert - var message = Assert.Throws(test).Message; + string message = Assert.Throws(test).Message; StringAssert.StartsWith(Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_view_commands, message); StringAssert.EndsWith("viewCommandsHandler", message); @@ -144,13 +179,15 @@ var applicationFeatureCommandHandler = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); // Call TestDelegate test = () => new GuiContextMenuItemFactory(applicationFeatureCommandHandler, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, new object()); @@ -167,18 +204,20 @@ var applicationFeatureCommandHandler = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); // Call TestDelegate test = () => new GuiContextMenuItemFactory(applicationFeatureCommandHandler, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, null); // Assert - var message = Assert.Throws(test).Message; + string message = Assert.Throws(test).Message; StringAssert.StartsWith(Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_data, message); StringAssert.EndsWith("dataObject", message); @@ -192,6 +231,7 @@ var commandHandlerMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var nodeData = new object(); viewCommandsMock.Expect(ch => ch.CanOpenViewFor(nodeData)).Return(false); @@ -200,11 +240,12 @@ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData); // Call - var item = contextMenuFactory.CreateOpenItem(); + ToolStripItem item = contextMenuFactory.CreateOpenItem(); item.PerformClick(); // Assert @@ -223,6 +264,7 @@ var commandHandlerMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var nodeData = new object(); viewCommandsMock.Expect(ch => ch.CanOpenViewFor(nodeData)).Return(true); @@ -232,11 +274,12 @@ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData); // Call - var item = contextMenuFactory.CreateOpenItem(); + ToolStripItem item = contextMenuFactory.CreateOpenItem(); item.PerformClick(); // Assert @@ -257,6 +300,7 @@ var commandHandlerMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var nodeData = new object(); exportCommandHandlerMock.Expect(ch => ch.CanExportFrom(nodeData)).Return(hasExportersForNodeData); @@ -270,11 +314,12 @@ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData); // Call - var item = contextMenuFactory.CreateExportItem(); + ToolStripItem item = contextMenuFactory.CreateExportItem(); item.PerformClick(); // Assert @@ -295,6 +340,7 @@ var commandHandlerMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var nodeData = new object(); importCommandHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(canImportOn); @@ -308,11 +354,12 @@ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData); // Call - var item = contextMenuFactory.CreateImportItem(); + ToolStripItem item = contextMenuFactory.CreateImportItem(); item.PerformClick(); // Assert @@ -325,6 +372,46 @@ } [Test] + [TestCase(true)] + [TestCase(false)] + public void CreateUpdateItem_Always_ItemWithPropertiesSet(bool canUpdateOn) + { + // Setup + var commandHandlerMock = mocks.StrictMock(); + var importCommandHandlerMock = mocks.StrictMock(); + var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); + var viewCommandsMock = mocks.StrictMock(); + var nodeData = new object(); + updateCommandHandlerMock.Expect(ch => ch.CanUpdateOn(nodeData)).Return(canUpdateOn); + if (canUpdateOn) + { + updateCommandHandlerMock.Expect(ch => ch.UpdateOn(nodeData)); + } + + mocks.ReplayAll(); + + var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, + importCommandHandlerMock, + exportCommandHandlerMock, + updateCommandHandlerMock, + viewCommandsMock, + nodeData); + + // Call + ToolStripItem item = contextMenuFactory.CreateUpdateItem(); + item.PerformClick(); + + // Assert + Assert.AreEqual(Resources.Update, item.Text); + Assert.AreEqual(Resources.Update_ToolTip, item.ToolTipText); + TestHelper.AssertImagesAreEqual(Resources.RefreshIcon, item.Image); + Assert.AreEqual(canUpdateOn, item.Enabled); + + mocks.VerifyAll(); + } + + [Test] [TestCase(null)] [TestCase("")] [TestCase(" ")] @@ -337,6 +424,7 @@ var commandHandlerMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var nodeData = new object(); @@ -345,6 +433,7 @@ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData); @@ -367,6 +456,7 @@ var commandHandlerMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var nodeData = new object(); @@ -375,6 +465,7 @@ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData); @@ -397,6 +488,7 @@ var commandHandlerMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var nodeData = new object(); @@ -405,6 +497,7 @@ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData); @@ -430,6 +523,7 @@ var commandHandlerMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var nodeData = new object(); importCommandHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(canImportOn); @@ -443,11 +537,12 @@ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData); // Call - var item = contextMenuFactory.CreateCustomImportItem(text, toolTip, image); + ToolStripItem item = contextMenuFactory.CreateCustomImportItem(text, toolTip, image); item.PerformClick(); // Assert @@ -468,6 +563,7 @@ var commandHandlerMock = mocks.StrictMock(); var importCommandHandlerMock = mocks.StrictMock(); var exportCommandHandlerMock = mocks.StrictMock(); + var updateCommandHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var nodeData = new object(); commandHandlerMock.Expect(ch => ch.CanShowPropertiesFor(nodeData)).Return(hasPropertyInfoForNodeData); @@ -479,13 +575,14 @@ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, importCommandHandlerMock, exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, nodeData); mocks.ReplayAll(); // Call - var item = contextMenuFactory.CreatePropertiesItem(); + ToolStripItem item = contextMenuFactory.CreatePropertiesItem(); item.PerformClick(); // Assert Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj =================================================================== diff -u -r6a5d7b40b7ba4dcb73e393075338352d194e97c2 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 6a5d7b40b7ba4dcb73e393075338352d194e97c2) +++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 45440093089496f59ed420e772136756c229e30b) @@ -85,6 +85,7 @@ + @@ -96,6 +97,7 @@ + @@ -117,6 +119,7 @@ TestView.cs + Index: Core/Common/test/Core.Common.Gui.Test/DialogBasedInquiryHelperTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/DialogBasedInquiryHelperTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/DialogBasedInquiryHelperTest.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,250 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.IO; +using System.Threading; +using System.Windows.Forms; +using Core.Common.TestUtil; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Common.Gui.Test +{ + [TestFixture] + public class DialogBasedInquiryHelperTest : NUnitFormTest + { + private IWin32Window dialogParent; + private MockRepository mocks; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + dialogParent = mocks.StrictMock(); + } + + public override void TearDown() + { + mocks.VerifyAll(); + } + + [Test] + public void DefaultConstructor_CreatesNewInquiryHelper() + { + // Setup + mocks.ReplayAll(); + + // Call + var helper = new DialogBasedInquiryHelper(dialogParent); + + // Assert + Assert.IsInstanceOf(helper); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void GetSourceFileLocation_Always_ShowsOpenFileDialog() + { + // Setup + mocks.ReplayAll(); + + var helper = new DialogBasedInquiryHelper(dialogParent); + + string windowName = null; + DialogBoxHandler = (name, wnd) => + { + var tester = new OpenFileDialogTester(wnd); + windowName = name; + tester.ClickCancel(); + }; + + // Call + helper.GetSourceFileLocation(); + + // Assert + Assert.AreEqual("Openen", windowName); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void GetSourceFileLocation_CancelClicked_ResultFileSelectedIsFalse() + { + // Setup + mocks.ReplayAll(); + + var helper = new DialogBasedInquiryHelper(dialogParent); + + DialogBoxHandler = (name, wnd) => + { + var tester = new OpenFileDialogTester(wnd); + tester.ClickCancel(); + }; + + // Call + var result = helper.GetSourceFileLocation(); + + // Assert + Assert.IsFalse(result.HasFilePath); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void GetSourceFileLocation_ExistingFileSelected_ResultFileSelectedIsTrueFileNameSet() + { + // Setup + mocks.ReplayAll(); + + var helper = new DialogBasedInquiryHelper(dialogParent); + string expectedFilePath = Path.GetFullPath(Path.GetRandomFileName()); + + DialogBoxHandler = (name, wnd) => + { + var tester = new OpenFileDialogTester(wnd); + tester.OpenFile(expectedFilePath); + }; + + using (new FileDisposeHelper(expectedFilePath)) + { + // Call + var result = helper.GetSourceFileLocation(); + + // Assert + Assert.IsTrue(result.HasFilePath); + Assert.AreEqual(expectedFilePath, result.FilePath); + } + } + + [Test] + [Apartment(ApartmentState.STA)] + public void GetTargetFileLocation_Always_ShowsOpenFileDialog() + { + // Setup + mocks.ReplayAll(); + + var helper = new DialogBasedInquiryHelper(dialogParent); + + string windowName = null; + DialogBoxHandler = (name, wnd) => + { + var tester = new OpenFileDialogTester(wnd); + windowName = name; + tester.ClickCancel(); + }; + + // Call + helper.GetTargetFileLocation(); + + // Assert + Assert.AreEqual("Opslaan als", windowName); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void GetTargetFileLocation_CancelClicked_ResultFileSelectedIsFalse() + { + // Setup + mocks.ReplayAll(); + + var helper = new DialogBasedInquiryHelper(dialogParent); + + DialogBoxHandler = (name, wnd) => + { + var tester = new SaveFileDialogTester(wnd); + tester.ClickCancel(); + }; + + // Call + var result = helper.GetTargetFileLocation(); + + // Assert + Assert.IsFalse(result.HasFilePath); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void GetTargetFileLocation_FileSelected_ResultFileSelectedIsTrueFileNameSet() + { + // Setup + mocks.ReplayAll(); + + var helper = new DialogBasedInquiryHelper(dialogParent); + string expectedFilePath = Path.GetFullPath(Path.GetRandomFileName()); + + DialogBoxHandler = (name, wnd) => + { + var tester = new SaveFileDialogTester(wnd); + tester.SaveFile(expectedFilePath); + }; + + // Call + var result = helper.GetTargetFileLocation(); + + // Assert + Assert.IsTrue(result.HasFilePath); + Assert.AreEqual(expectedFilePath, result.FilePath); + } + + [Test] + [Apartment(ApartmentState.STA)] + [TestCase(true)] + [TestCase(false)] + public void InquireContinuation_OkOrCancelClicked_ReturnExpectedResult(bool confirm) + { + // Setup + mocks.ReplayAll(); + + dialogParent.Expect(d => d.Handle).Repeat.AtLeastOnce().Return(default(IntPtr)); + mocks.ReplayAll(); + + var helper = new DialogBasedInquiryHelper(dialogParent); + + string expectedQuery = "Are you sure you want to do this?"; + string expectedTitle = "Bevestigen"; + string query = null; + string title = null; + + DialogBoxHandler = (name, wnd) => + { + var tester = new MessageBoxTester(wnd); + query = tester.Text; + title = tester.Title; + if (confirm) + { + tester.ClickOk(); + } + else + { + tester.ClickCancel(); + } + }; + + // Call + var result = helper.InquireContinuation(expectedQuery); + + // Assert + Assert.AreEqual(expectedQuery, query); + Assert.AreEqual(expectedTitle, title); + Assert.AreEqual(confirm, result); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/ExpectedFileTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/ExpectedFileTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/ExpectedFileTest.cs (revision 45440093089496f59ed420e772136756c229e30b) @@ -0,0 +1,66 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using NUnit.Framework; + +namespace Core.Common.Gui.Test +{ + [TestFixture] + public class ExpectedFileTest + { + [Test] + public void Filter_DefaultConstructor_AllFileFilter() + { + // Call + var expected = new ExpectedFile(); + + // Assert + Assert.AreEqual("Alle bestanden (*.*)|*.*", expected.Filter); + } + + [Test] + public void Filter_WithExtension_FilterBasedOnExtension() + { + // Setup + const string someExtension = "ext"; + + // Call + var expected = new ExpectedFile(someExtension); + + // Assert + Assert.AreEqual("EXT-bestanden (*.ext)|*.ext", expected.Filter); + } + + [Test] + public void Filter_WithDescriptionAndExtension_FilterBasedOnExtension() + { + // Setup + const string someExtension = "ext"; + const string someDescription = "Bestanden met .ext extensie"; + + // Call + var expected = new ExpectedFile(someExtension, someDescription); + + // Assert + Assert.AreEqual("Bestanden met .ext extensie (*.ext)|*.ext", expected.Filter); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.TestUtil.Test/ContextMenu/CustomItemsOnlyContextMenuBuilderTest.cs =================================================================== diff -u -r0324c332753d36bb804a804b9757ef1cd336435f -r45440093089496f59ed420e772136756c229e30b --- Core/Common/test/Core.Common.Gui.TestUtil.Test/ContextMenu/CustomItemsOnlyContextMenuBuilderTest.cs (.../CustomItemsOnlyContextMenuBuilderTest.cs) (revision 0324c332753d36bb804a804b9757ef1cd336435f) +++ Core/Common/test/Core.Common.Gui.TestUtil.Test/ContextMenu/CustomItemsOnlyContextMenuBuilderTest.cs (.../CustomItemsOnlyContextMenuBuilderTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -147,6 +147,19 @@ } [Test] + public void AddUpdateItem_WhenBuild_StubbedItemAddedToContextMenu() + { + // Setup + var builder = new CustomItemsOnlyContextMenuBuilder(); + + // Call + ContextMenuStrip result = builder.AddUpdateItem().Build(); + + // Assert + AssertStubbedContextMenuItem(result); + } + + [Test] public void AddCustomImportItem_WhenBuild_StubbedItemAddedToContextMenu() { // Setup Index: Core/Common/test/Core.Common.Gui.TestUtil/ContextMenu/CustomItemsOnlyContextMenuBuilder.cs =================================================================== diff -u -r0d3788fdf7aa5b050974f69bcea4f8e71a096d58 -r45440093089496f59ed420e772136756c229e30b --- Core/Common/test/Core.Common.Gui.TestUtil/ContextMenu/CustomItemsOnlyContextMenuBuilder.cs (.../CustomItemsOnlyContextMenuBuilder.cs) (revision 0d3788fdf7aa5b050974f69bcea4f8e71a096d58) +++ Core/Common/test/Core.Common.Gui.TestUtil/ContextMenu/CustomItemsOnlyContextMenuBuilder.cs (.../CustomItemsOnlyContextMenuBuilder.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -115,6 +115,16 @@ return this; } + /// + /// Adds a dummy to the . + /// + /// The . + public IContextMenuBuilder AddUpdateItem() + { + contextMenu.Items.Add(StubItem()); + return this; + } + public IContextMenuBuilder AddCustomImportItem(string text, string toolTip, Image image) { contextMenu.Items.Add(StubItem()); Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapDataCollectionTreeNodeInfoTest.cs =================================================================== diff -u -r8b3f995635bbd317936d1607058bb0e80c3c5508 -r45440093089496f59ed420e772136756c229e30b --- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapDataCollectionTreeNodeInfoTest.cs (.../MapDataCollectionTreeNodeInfoTest.cs) (revision 8b3f995635bbd317936d1607058bb0e80c3c5508) +++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapDataCollectionTreeNodeInfoTest.cs (.../MapDataCollectionTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -294,14 +294,16 @@ var importCommandHandlerMock = mocks.Stub(); importCommandHandlerMock.Stub(ich => ich.CanImportOn(null)).IgnoreArguments().Return(true); var exportCommandHandlerMock = mocks.Stub(); + var updateCommandHandlerMock = mocks.Stub(); var viewCommandsMock = mocks.Stub(); using (var treeViewControl = new TreeViewControl()) { // Call var builder = new ContextMenuBuilder(applicationFeatureCommandsStub, importCommandHandlerMock, - exportCommandHandlerMock, + exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, mapDataCollection, treeViewControl); @@ -355,14 +357,16 @@ var importCommandHandlerMock = mocks.Stub(); importCommandHandlerMock.Stub(ich => ich.CanImportOn(null)).IgnoreArguments().Return(true); var exportCommandHandlerMock = mocks.Stub(); + var updateCommandHandlerMock = mocks.Stub(); var viewCommandsMock = mocks.Stub(); using (var treeViewControl = new TreeViewControl()) { // Call var builder = new ContextMenuBuilder(applicationFeatureCommandsStub, importCommandHandlerMock, - exportCommandHandlerMock, + exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, mapDataCollection, treeViewControl); @@ -426,14 +430,16 @@ var importCommandHandlerMock = mocks.Stub(); importCommandHandlerMock.Stub(ich => ich.CanImportOn(null)).IgnoreArguments().Return(true); var exportCommandHandlerMock = mocks.Stub(); + var updateCommandHandlerMock = mocks.Stub(); var viewCommandsMock = mocks.Stub(); using (var treeViewControl = new TreeViewControl()) { // Call var builder = new ContextMenuBuilder(applicationFeatureCommandsStub, importCommandHandlerMock, - exportCommandHandlerMock, + exportCommandHandlerMock, + updateCommandHandlerMock, viewCommandsMock, mapDataCollection, treeViewControl); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs =================================================================== diff -u -rd30b839df8d71c1742a96ada6e422b44cdc9efff -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision d30b839df8d71c1742a96ada6e422b44cdc9efff) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -51,6 +51,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -61,6 +62,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -89,6 +91,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var failureMechanismMock = mocks.StrictMock(); @@ -101,6 +104,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -129,6 +133,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var calculationWithOutputMock = mocks.StrictMock(); @@ -148,6 +153,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder); @@ -175,6 +181,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -186,6 +193,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -215,6 +223,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var calculationWithOutputMock = mocks.StrictMock(); calculationWithOutputMock.Expect(c => c.HasOutput).Return(true); @@ -230,6 +239,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismMock, treeViewControl); @@ -258,6 +268,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var failureMechanism = mocks.Stub(); failureMechanism.Stub(fm => fm.Calculations).Return(new List()); @@ -269,6 +280,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanism, treeViewControl); @@ -300,6 +312,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var failureMechanismMock = mocks.StrictMock(); failureMechanismMock.Expect(fm => fm.IsRelevant).Return(isRelevant); @@ -312,6 +325,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismMock, treeViewControl); @@ -340,6 +354,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var calculationWithOutputMock = mocks.StrictMock(); @@ -352,6 +367,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationWithOutputMock, treeViewControl); @@ -380,6 +396,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var calculationWithoutOutputMock = mocks.StrictMock(); @@ -392,6 +409,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationWithoutOutputMock, treeViewControl); @@ -644,6 +662,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var failureMechanisMock = mocks.StrictMock(); @@ -657,6 +676,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculation, treeViewControl); @@ -685,6 +705,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var failureMechanisMock = mocks.StrictMock(); @@ -698,6 +719,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculation, treeViewControl); @@ -733,6 +755,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var failureMechanismMock = mocks.StrictMock(); @@ -746,6 +769,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculation, treeViewControl); @@ -774,6 +798,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var failureMechanismMock = mocks.StrictMock(); @@ -787,6 +812,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculation, treeViewControl); @@ -822,6 +848,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -846,6 +873,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -874,6 +902,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -887,6 +916,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -916,6 +946,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -940,6 +971,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -971,6 +1003,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -984,6 +1017,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -1019,6 +1053,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -1043,6 +1078,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -1071,6 +1107,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -1084,6 +1121,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -1113,6 +1151,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -1137,6 +1176,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -1168,6 +1208,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -1181,6 +1222,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, calculationGroup, treeViewControl); @@ -1216,6 +1258,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); @@ -1232,6 +1275,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); @@ -1259,6 +1303,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); @@ -1272,6 +1317,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); @@ -1300,6 +1346,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); @@ -1316,6 +1363,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); @@ -1346,6 +1394,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); @@ -1359,6 +1408,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); @@ -1393,6 +1443,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); @@ -1409,6 +1460,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); @@ -1436,6 +1488,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); @@ -1449,6 +1502,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); @@ -1477,6 +1531,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); @@ -1493,6 +1548,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); @@ -1526,6 +1582,7 @@ var applicationFeatureCommandsMock = mocks.StrictMock(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); @@ -1539,6 +1596,7 @@ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rc990bf404015584981f3ec1d22ecec12a7b037f3 -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision c990bf404015584981f3ec1d22ecec12a7b037f3) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -394,13 +394,15 @@ var applicationFeatureCommandHandlerStub = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandlerMock = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandlerStub, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandlerMock, nodeData, treeViewControl); @@ -446,13 +448,15 @@ var applicationFeatureCommandHandlerStub = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandlerMock = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandlerStub, importHandlerMock, - exportHandlerMock, + exportHandlerMock, + updateHandlerMock, viewCommandsHandlerMock, nodeData, treeViewControl); @@ -593,13 +597,15 @@ var applicationFeatureCommandHandlerStub = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandlerMock = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandlerStub, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandlerMock, nodeData, treeViewControl); @@ -645,13 +651,15 @@ var applicationFeatureCommandHandlerStub = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandlerMock = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandlerStub, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandlerMock, nodeData, treeViewControl); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -rc990bf404015584981f3ec1d22ecec12a7b037f3 -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision c990bf404015584981f3ec1d22ecec12a7b037f3) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -192,6 +192,7 @@ var applicationFeatureCommandHandler = mockRepository.Stub(); var importCommandHandler = mockRepository.Stub(); var exportCommandHandler = mockRepository.Stub(); + var updateCommandHandler = mockRepository.Stub(); var viewCommandsHandler = mockRepository.Stub(); viewCommandsHandler.Stub(vch => vch.CanOpenViewFor(null)).IgnoreArguments().Return(true); @@ -212,6 +213,7 @@ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importCommandHandler, exportCommandHandler, + updateCommandHandler, viewCommandsHandler, context, treeViewControl); @@ -253,6 +255,7 @@ var applicationFeatureCommandHandler = mockRepository.Stub(); var importCommandHandler = mockRepository.Stub(); var exportCommandHandler = mockRepository.Stub(); + var updateCommandHandler = mockRepository.Stub(); var viewCommandsHandler = mockRepository.Stub(); viewCommandsHandler.Stub(vch => vch.CanOpenViewFor(null)).IgnoreArguments().Return(true); @@ -269,7 +272,8 @@ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importCommandHandler, - exportCommandHandler, + exportCommandHandler, + updateCommandHandler, viewCommandsHandler, context, treeViewControl); @@ -311,6 +315,7 @@ var applicationFeatureCommandHandler = mockRepository.Stub(); var importCommandHandler = mockRepository.Stub(); var exportCommandHandler = mockRepository.Stub(); + var updateCommandHandler = mockRepository.Stub(); var viewCommandsHandler = mockRepository.Stub(); viewCommandsHandler.Stub(vch => vch.CanOpenViewFor(null)).IgnoreArguments().Return(true); @@ -330,7 +335,8 @@ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importCommandHandler, - exportCommandHandler, + exportCommandHandler, + updateCommandHandler, viewCommandsHandler, context, treeViewControl); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -496,10 +496,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -548,10 +550,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -606,10 +610,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -664,10 +670,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -732,10 +740,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -802,10 +812,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -854,10 +866,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -912,10 +926,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -970,10 +986,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1027,11 +1045,13 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var mainWindow = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1094,10 +1114,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1143,10 +1165,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1195,10 +1219,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, - exportHandler, + exportHandler, + updateHandler, viewCommands, context, treeViewControl); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -177,7 +177,7 @@ assessmentSection); // Call - var children = info.ChildNodeObjects(groupContext); + object[] children = info.ChildNodeObjects(groupContext); // Assert CollectionAssert.IsEmpty(children); @@ -202,7 +202,7 @@ assessmentSection); // Call - var children = info.ChildNodeObjects(nodeData).ToArray(); + object[] children = info.ChildNodeObjects(nodeData).ToArray(); // Assert Assert.AreEqual(failureMechanism.WaveConditionsCalculationGroup.Children.Count, children.Length); @@ -233,13 +233,15 @@ var applicationFeatureCommandHandler = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); var viewCommandsHandler = mocks.StrictMock(); var treeViewControl = mocks.StrictMock(); var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -338,13 +340,15 @@ var applicationFeatureCommandHandler = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); var viewCommandsHandler = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -443,13 +447,15 @@ var applicationFeatureCommandHandler = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); var viewCommandsHandler = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -846,7 +852,7 @@ // Assert TestHelper.AssertLogMessages(test, m => { - var messages = m.ToArray(); + string[] messages = m.ToArray(); Assert.AreEqual(4, messages.Length); StringAssert.StartsWith("Validatie van 'A' gestart om: ", messages[0]); StringAssert.StartsWith("Validatie van 'A' beëindigd om: ", messages[1]); @@ -869,8 +875,8 @@ observerB.Expect(o => o.UpdateObserver()); var group = new CalculationGroup(); - var calculationA = GetValidCalculation(); - var calculationB = GetValidCalculation(); + GrassCoverErosionOutwardsWaveConditionsCalculation calculationA = GetValidCalculation(); + GrassCoverErosionOutwardsWaveConditionsCalculation calculationB = GetValidCalculation(); calculationA.Attach(observerA); calculationB.Attach(observerB); group.Children.Add(calculationA); @@ -920,7 +926,7 @@ // Assert TestHelper.AssertLogMessages(test, m => { - var messages = m.ToArray(); + string[] messages = m.ToArray(); Assert.AreEqual(28, messages.Length); StringAssert.StartsWith("Berekening van 'Nieuwe berekening' gestart om: ", messages[2]); StringAssert.StartsWith("Berekening van 'Nieuwe berekening' beëindigd om: ", messages[12]); @@ -974,7 +980,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - var clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; + ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; // Assert Assert.IsFalse(clearAllOutputItem.Enabled); @@ -989,8 +995,8 @@ string hrdPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); var group = new CalculationGroup(); - var calculationA = GetValidCalculation(); - var calculationB = GetValidCalculation(); + GrassCoverErosionOutwardsWaveConditionsCalculation calculationA = GetValidCalculation(); + GrassCoverErosionOutwardsWaveConditionsCalculation calculationB = GetValidCalculation(); group.Children.Add(calculationA); group.Children.Add(calculationB); @@ -1025,7 +1031,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - var clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; + ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; // Assert Assert.IsFalse(clearAllOutputItem.Enabled); @@ -1050,9 +1056,9 @@ } var group = new CalculationGroup(); - var calculationA = GetValidCalculation(); + GrassCoverErosionOutwardsWaveConditionsCalculation calculationA = GetValidCalculation(); calculationA.Output = new GrassCoverErosionOutwardsWaveConditionsOutput(Enumerable.Empty()); - var calculationB = GetValidCalculation(); + GrassCoverErosionOutwardsWaveConditionsCalculation calculationB = GetValidCalculation(); calculationB.Output = new GrassCoverErosionOutwardsWaveConditionsOutput(Enumerable.Empty()); group.Children.Add(calculationA); group.Children.Add(calculationB); @@ -1164,7 +1170,7 @@ // Assert Assert.AreEqual(2, group.Children.Count); - var newlyAddedItem = group.Children.Last(); + ICalculationBase newlyAddedItem = group.Children.Last(); Assert.IsInstanceOf(newlyAddedItem); Assert.AreEqual("Nieuwe map (1)", newlyAddedItem.Name, "An item with the same name default name already exists, therefore '(1)' needs to be appended."); @@ -1188,10 +1194,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1239,10 +1247,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -rc990bf404015584981f3ec1d22ecec12a7b037f3 -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs) (revision c990bf404015584981f3ec1d22ecec12a7b037f3) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -189,6 +189,7 @@ var applicationFeatureCommandHandler = mockRepository.Stub(); var importCommandHandler = mockRepository.Stub(); var exportCommandHandler = mockRepository.Stub(); + var updateCommandHandler = mockRepository.Stub(); var viewCommandsHandler = mockRepository.Stub(); viewCommandsHandler.Stub(vch => vch.CanOpenViewFor(null)).IgnoreArguments().Return(true); @@ -209,6 +210,7 @@ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importCommandHandler, exportCommandHandler, + updateCommandHandler, viewCommandsHandler, context, treeViewControl); @@ -250,6 +252,7 @@ var applicationFeatureCommandHandler = mockRepository.Stub(); var importCommandHandler = mockRepository.Stub(); var exportCommandHandler = mockRepository.Stub(); + var updateCommandHandler = mockRepository.Stub(); var viewCommandsHandler = mockRepository.Stub(); viewCommandsHandler.Stub(vch => vch.CanOpenViewFor(null)).IgnoreArguments().Return(true); @@ -266,7 +269,8 @@ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importCommandHandler, - exportCommandHandler, + exportCommandHandler, + updateCommandHandler, viewCommandsHandler, context, treeViewControl); @@ -308,6 +312,7 @@ var applicationFeatureCommandHandler = mockRepository.Stub(); var importCommandHandler = mockRepository.Stub(); var exportCommandHandler = mockRepository.Stub(); + var updateCommandHandler = mockRepository.Stub(); var viewCommandsHandler = mockRepository.Stub(); viewCommandsHandler.Stub(vch => vch.CanOpenViewFor(null)).IgnoreArguments().Return(true); @@ -328,6 +333,7 @@ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importCommandHandler, exportCommandHandler, + updateCommandHandler, viewCommandsHandler, context, treeViewControl); Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelChangeHandler.cs =================================================================== diff -u -r76a7de2e77e45645d0e7e485e03333baf9cc3b0d -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelChangeHandler.cs (.../StochasticSoilModelChangeHandler.cs) (revision 76a7de2e77e45645d0e7e485e03333baf9cc3b0d) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/StochasticSoilModelChangeHandler.cs (.../StochasticSoilModelChangeHandler.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -22,11 +22,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Windows.Forms; +using Core.Common.Gui; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Importer; using Ringtoets.Piping.Plugin.Properties; -using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; namespace Ringtoets.Piping.Plugin.FileImporter { @@ -37,14 +36,20 @@ public class StochasticSoilModelChangeHandler : IStochasticSoilModelChangeHandler { private readonly PipingFailureMechanism failureMechanism; + private readonly IInquiryHelper inquiryHandler; - public StochasticSoilModelChangeHandler(PipingFailureMechanism failureMechanism) + public StochasticSoilModelChangeHandler(PipingFailureMechanism failureMechanism, IInquiryHelper inquiryHandler) { if (failureMechanism == null) { throw new ArgumentNullException(nameof(failureMechanism)); } + if (inquiryHandler == null) + { + throw new ArgumentNullException(nameof(inquiryHandler)); + } this.failureMechanism = failureMechanism; + this.inquiryHandler = inquiryHandler; } public bool RequireConfirmation() @@ -61,12 +66,8 @@ public bool InquireConfirmation() { - DialogResult result = MessageBox.Show( - Resources.StochasticSoilModelChangeHandler_When_updating_StochasticSoilModel_definitions_assigned_to_calculations_output_will_be_cleared_confirm, - CoreCommonBaseResources.Confirm, - MessageBoxButtons.OKCancel); - - return result == DialogResult.OK; + return inquiryHandler.InquireContinuation( + Resources.StochasticSoilModelChangeHandler_When_updating_StochasticSoilModel_definitions_assigned_to_calculations_output_will_be_cleared_confirm); } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -re955b2483ae95b097dd76135a3a95bb7ed05d496 -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision e955b2483ae95b097dd76135a3a95bb7ed05d496) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -28,10 +28,12 @@ using Core.Common.Base; using Core.Common.Base.Service; using Core.Common.Controls.TreeView; +using Core.Common.Gui; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms; using Core.Common.Gui.Forms.ProgressDialog; using Core.Common.Gui.Plugin; +using Core.Common.Gui.Properties; using log4net; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; @@ -115,14 +117,54 @@ Name = PipingFormsResources.StochasticSoilModelCollection_DisplayName, Category = RingtoetsCommonFormsResources.Ringtoets_Category, Image = PipingFormsResources.PipingSoilProfileIcon, - FileFilter = $"{PipingPluginResources.Soil_file_name} (*.soil)|*.soil", - IsEnabled = context => context.AssessmentSection.ReferenceLine != null, - CreateFileImporter = (context, filePath) => new StochasticSoilModelImporter(context.WrappedData, - filePath, - new StochasticSoilModelReplaceDataStrategy()) + FileFilter = StochasticSoilModelFileFilter, + IsEnabled = StochasticSoilModelImporterEnabled, + CreateFileImporter = (context, filePath) => StochasticSoilModelImporter(context, filePath, new StochasticSoilModelReplaceDataStrategy()), + VerifyUpdates = VerifyStochasticSoilModelUpdates }; } + public override IEnumerable GetUpdateInfos() + { + yield return new UpdateInfo + { + Name = PipingFormsResources.StochasticSoilModelCollection_DisplayName, + Category = RingtoetsCommonFormsResources.Ringtoets_Category, + Image = PipingFormsResources.PipingSoilProfileIcon, + FileFilter = new ExpectedFile("soil", PipingPluginResources.Soil_file_name), + IsEnabled = StochasticSoilModelImporterEnabled, + CurrentPath = context => context.WrappedData.SourcePath, + CreateFileImporter = (context, filePath) => StochasticSoilModelImporter(context, filePath, new StochasticSoilModelUpdateDataStrategy(context.FailureMechanism)), + VerifyUpdates = VerifyStochasticSoilModelUpdates + }; + } + + private static StochasticSoilModelImporter StochasticSoilModelImporter(StochasticSoilModelCollectionContext context, string filePath, IStochasticSoilModelUpdateModelStrategy updateStrategy) + { + return new StochasticSoilModelImporter(context.WrappedData, + filePath, + updateStrategy); + } + + private static bool StochasticSoilModelImporterEnabled(StochasticSoilModelCollectionContext context) + { + return context.AssessmentSection.ReferenceLine != null; + } + + private static string StochasticSoilModelFileFilter + { + get + { + return $"{PipingPluginResources.Soil_file_name} (*.soil)|*.soil"; + } + } + + private bool VerifyStochasticSoilModelUpdates(StochasticSoilModelCollectionContext context) + { + var changeHandler = new StochasticSoilModelChangeHandler(context.FailureMechanism, new DialogBasedInquiryHelper(Gui.MainWindow)); + return !changeHandler.RequireConfirmation() || changeHandler.InquireConfirmation(); + } + public override IEnumerable GetViewInfos() { yield return new ViewInfo @@ -518,10 +560,7 @@ { return Gui.Get(nodeData, treeViewControl) .AddImportItem() - .AddCustomItem( - CreateUpdateStochasticSoilModelsItem( - nodeData.WrappedData, - nodeData.FailureMechanism)) + .AddUpdateItem() .AddSeparator() .AddDeleteChildrenItem() .AddSeparator() @@ -532,77 +571,6 @@ .Build(); } - private StrictContextMenuItem CreateUpdateStochasticSoilModelsItem(ObservableCollectionWithSourcePath soilModelCollection, PipingFailureMechanism failureMechanism) - { - var enabled = soilModelCollection.SourcePath != null; - - return new StrictContextMenuItem( - PipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_Text, - enabled ? PipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_ToolTip : PipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_ToolTip_No_SourcePath_set, - PipingPluginResources.RefreshIcon, - (sender, args) => UpdateStochasticSoilModelFromKnownSourceFile(soilModelCollection, failureMechanism)) - { - Enabled = enabled - }; - } - - private void UpdateStochasticSoilModelFromKnownSourceFile(ObservableCollectionWithSourcePath soilModelCollection, PipingFailureMechanism failureMechanism) - { - string updateFromPath = soilModelCollection.SourcePath; - if (!File.Exists(updateFromPath)) - { - updateFromPath = InquireUserForNewPath(); - } - - if (IsClearResultAllowed(failureMechanism) && updateFromPath != null) - { - RunUpdateStochasticSoilModel(soilModelCollection, failureMechanism, updateFromPath); - } - else - { - log.Info(string.Format( - PipingPluginResources.PipingPlugin_UpdateStochasticSoilModels_Update_of_StochasticSoilModels_from_File_0_canceled_by_user, - soilModelCollection.SourcePath)); - } - } - - private static bool IsClearResultAllowed(PipingFailureMechanism failureMechanism) - { - var changeHandler = new StochasticSoilModelChangeHandler(failureMechanism); - bool allowed = true; - bool requireConfirmation = changeHandler.RequireConfirmation(); - if (requireConfirmation) - { - allowed = changeHandler.InquireConfirmation(); - } - return allowed; - } - - private string InquireUserForNewPath() - { - var openFileDialog = new OpenFileDialog - { - Multiselect = false, - Title = PipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsFileDialog_Title, - Filter = $"{PipingPluginResources.Soil_file_name} (*.soil)|*.soil" - }; - if (openFileDialog.ShowDialog(Gui.MainWindow) == DialogResult.OK) - { - return openFileDialog.FileName; - } - return null; - } - - private void RunUpdateStochasticSoilModel(ObservableCollectionWithSourcePath soilModelCollection, PipingFailureMechanism failureMechanism, string sourceFilePath) - { - var importer = new StochasticSoilModelImporter(soilModelCollection, - sourceFilePath, - new StochasticSoilModelUpdateDataStrategy(failureMechanism)); - - var activity = new FileImportActivity(importer, PipingPluginResources.PipingPlugin_RunUpdateStochasticSoilModel_Update_StochasticSoilModels); - ActivityProgressDialogRunner.Run(Gui.MainWindow, activity); - } - #endregion #region RingtoetsPipingSurfaceLine TreeNodeInfo Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -r76a7de2e77e45645d0e7e485e03333baf9cc3b0d -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 76a7de2e77e45645d0e7e485e03333baf9cc3b0d) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -364,16 +364,6 @@ } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - public static System.Drawing.Bitmap RefreshIcon { - get { - object obj = ResourceManager.GetObject("RefreshIcon", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// /// Looks up a localized string similar to D-Soil Model bestand. /// public static string Soil_file_name { Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx =================================================================== diff -u -r76a7de2e77e45645d0e7e485e03333baf9cc3b0d -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 76a7de2e77e45645d0e7e485e03333baf9cc3b0d) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 45440093089496f59ed420e772136756c229e30b) @@ -195,10 +195,6 @@ Het uittredepunt moet landwaarts van het intredepunt liggen voor locatie {0}. - - - ..\Resources\table_refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Bijwerken van stochastische ondergrondmodellen. Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Resources/table_refresh.png =================================================================== diff -u -r673bf2f4f4de6006444aae3a10183f9442eb0f23 -r45440093089496f59ed420e772136756c229e30b Binary files differ Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj =================================================================== diff -u -ree74bbc714b9c3d6b46e7c7734640366ef197ef6 -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision ee74bbc714b9c3d6b46e7c7734640366ef197ef6) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 45440093089496f59ed420e772136756c229e30b) @@ -183,9 +183,6 @@ - - - true Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/Ringtoets.Piping.IO.TestUtil.csproj =================================================================== diff -u -ra59b471e3b6a02319f91b7317b3814a099ef0221 -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/Ringtoets.Piping.IO.TestUtil.csproj (.../Ringtoets.Piping.IO.TestUtil.csproj) (revision a59b471e3b6a02319f91b7317b3814a099ef0221) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/Ringtoets.Piping.IO.TestUtil.csproj (.../Ringtoets.Piping.IO.TestUtil.csproj) (revision 45440093089496f59ed420e772136756c229e30b) @@ -55,7 +55,6 @@ Properties\GlobalAssembly.cs - Fisheye: Tag 45440093089496f59ed420e772136756c229e30b refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.IO.TestUtil/TestStochasticSoilModelChangeHandler.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelChangeHandlerTest.cs =================================================================== diff -u -r76a7de2e77e45645d0e7e485e03333baf9cc3b0d -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelChangeHandlerTest.cs (.../StochasticSoilModelChangeHandlerTest.cs) (revision 76a7de2e77e45645d0e7e485e03333baf9cc3b0d) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/StochasticSoilModelChangeHandlerTest.cs (.../StochasticSoilModelChangeHandlerTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -20,10 +20,11 @@ // All rights reserved. using System; +using Core.Common.Gui; using NUnit.Extensions.Forms; using NUnit.Framework; +using Rhino.Mocks; using Ringtoets.Piping.Data; -using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.IO.Importer; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Plugin.FileImporter; @@ -36,120 +37,115 @@ [Test] public void Constructor_WithoutFailureMechanism_ThrowsArgumentNullException() { + // Setup + var mockRepository = new MockRepository(); + var inquiryHandler = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + // Call - TestDelegate test = () => new StochasticSoilModelChangeHandler(null); + TestDelegate test = () => new StochasticSoilModelChangeHandler(null, inquiryHandler); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("failureMechanism", paramName); + mockRepository.VerifyAll(); } [Test] - public void Constructor_WithFailureMechanism_ImplementsExpectedInterface() + public void Constructor_WithoutInquiryHandler_ThrowsArgumentNullException() { // Call - var handler = new StochasticSoilModelChangeHandler(new PipingFailureMechanism()); + TestDelegate test = () => new StochasticSoilModelChangeHandler(new PipingFailureMechanism(), null); // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("inquiryHandler", paramName); + } + + [Test] + public void Constructor_WithParameters_ImplementsExpectedInterface() + { + // Setup + var mockRepository = new MockRepository(); + var inquiryHandler = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + // Call + var handler = new StochasticSoilModelChangeHandler(new PipingFailureMechanism(), inquiryHandler); + + // Assert Assert.IsInstanceOf(handler); + mockRepository.VerifyAll(); } [Test] public void RequireConfirmation_FailureMechanismWithCalculationWithoutOutput_ReturnFalse() { // Setup + var mockRepository = new MockRepository(); + var inquiryHandler = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new PipingCalculationScenario(new GeneralPipingInput())); - var handler = new StochasticSoilModelChangeHandler(failureMechanism); + var handler = new StochasticSoilModelChangeHandler(failureMechanism, inquiryHandler); // Call bool requireConfirmation = handler.RequireConfirmation(); // Assert Assert.IsFalse(requireConfirmation); + mockRepository.VerifyAll(); } [Test] public void RequireConfirmation_FailureMechanismWithCalculationWithOutput_ReturnTrue() { // Setup + var mockRepository = new MockRepository(); + var inquiryHandler = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + var failureMechanism = new PipingFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new PipingCalculationScenario(new GeneralPipingInput()) { Output = new TestPipingOutput() }); - var handler = new StochasticSoilModelChangeHandler(failureMechanism); + var handler = new StochasticSoilModelChangeHandler(failureMechanism, inquiryHandler); // Call bool requireConfirmation = handler.RequireConfirmation(); // Assert Assert.IsTrue(requireConfirmation); + mockRepository.VerifyAll(); } [Test] - public void InquireConfirmation_Always_ShowsConfirmationDialog() + [TestCase(true)] + [TestCase(false)] + public void InquireConfirmation_Always_ShowsConfirmationDialogReturnResultOfInquiry(bool expectedResult) { // Setup - var handler = new StochasticSoilModelChangeHandler(new PipingFailureMechanism()); - - string dialogText = string.Empty; - - DialogBoxHandler = (name, wnd) => - { - var tester = new MessageBoxTester(wnd); - dialogText = tester.Text; - tester.ClickCancel(); - }; - - // Call - handler.InquireConfirmation(); - - // Assert const string message = "Wanneer ondergrondschematisaties wijzigen als gevolg van het bijwerken, " + "zullen de resultaten van berekeningen die deze ondergrondschematisaties worden " + "verwijderd. Weet u zeker dat u wilt doorgaan?"; - Assert.AreEqual(message, dialogText); - } - [Test] - public void InquireConfirmation_PressOkInMessageBox_ReturnsTrue() - { - // Setup - var handler = new StochasticSoilModelChangeHandler(new PipingFailureMechanism()); - - DialogBoxHandler = (name, wnd) => - { - var tester = new MessageBoxTester(wnd); - tester.ClickOk(); - }; + var mockRepository = new MockRepository(); + var inquiryHandler = mockRepository.StrictMock(); + inquiryHandler.Expect(ih => ih.InquireContinuation(message)).Return(expectedResult); + mockRepository.ReplayAll(); - // Call - var confirmed = handler.InquireConfirmation(); + var handler = new StochasticSoilModelChangeHandler(new PipingFailureMechanism(), inquiryHandler); - // Assert - Assert.IsTrue(confirmed); - } - - [Test] - public void InquireConfirmation_PressCancelInMessageBox_ReturnsFalse() - { - // Setup - var handler = new StochasticSoilModelChangeHandler(new PipingFailureMechanism()); - - DialogBoxHandler = (name, wnd) => - { - var tester = new MessageBoxTester(wnd); - tester.ClickCancel(); - }; - // Call - var confirmed = handler.InquireConfirmation(); + var result = handler.InquireConfirmation(); // Assert - Assert.IsFalse(confirmed); + Assert.AreEqual(expectedResult, result); + mockRepository.VerifyAll(); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r6ce3cfa19ef59b12462bae4a77e9a7ee5a05e28c -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 6ce3cfa19ef59b12462bae4a77e9a7ee5a05e28c) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -203,12 +203,14 @@ var applicationFeatureCommandHandler = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandler = mocks.StrictMock(); var treeViewControl = mocks.StrictMock(); var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -308,6 +310,7 @@ var applicationFeatureCommandHandler = mocks.Stub(); var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandler = mocks.StrictMock(); viewCommandsHandler.Expect(vc => vc.CanOpenViewFor(nodeData)).Return(true); @@ -317,6 +320,7 @@ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rc990bf404015584981f3ec1d22ecec12a7b037f3 -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs (.../PipingFailureMechanismContextTreeNodeInfoTest.cs) (revision c990bf404015584981f3ec1d22ecec12a7b037f3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs (.../PipingFailureMechanismContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -316,13 +316,15 @@ var applicationFeatureCommandHandler = mocks.Stub(); var importCommandHandler = mocks.Stub(); var exportCommandHandler = mocks.Stub(); + var updateCommandHandler = mocks.Stub(); var viewCommandsHandler = mocks.Stub(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importCommandHandler, exportCommandHandler, + updateCommandHandler, viewCommandsHandler, failureMechanismContext, treeViewControl); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs =================================================================== diff -u -rc990bf404015584981f3ec1d22ecec12a7b037f3 -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (.../StochasticSoilModelCollectionContextTreeNodeInfoTest.cs) (revision c990bf404015584981f3ec1d22ecec12a7b037f3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/StochasticSoilModelCollectionContextTreeNodeInfoTest.cs (.../StochasticSoilModelCollectionContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -44,7 +44,6 @@ using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; -using RingtoetsPipingPluginResources = Ringtoets.Piping.Plugin.Properties.Resources; namespace Ringtoets.Piping.Plugin.Test.TreeNodeInfos { @@ -247,7 +246,7 @@ using (mocks.Ordered()) { menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock); - menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddUpdateItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); @@ -260,7 +259,10 @@ using (var treeViewControl = new TreeViewControl()) { - var context = new StochasticSoilModelCollectionContext(new ObservableCollectionWithSourcePath(), new PipingFailureMechanism(), assessmentSection); + var context = new StochasticSoilModelCollectionContext( + new ObservableCollectionWithSourcePath(), + new PipingFailureMechanism(), + assessmentSection); var gui = mocks.Stub(); gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilderMock); @@ -274,222 +276,6 @@ // Assert // Assert expectancies are called in TearDown() } - - [Test] - [TestCase(false)] - [TestCase(true)] - public void ContextMenuStrip_WithOrWithoutPathToSoilModelsSource_UpdateStochasticSoilModelsItemEnabledWhenPathSet(bool sourcePathSet) - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var pipingFailureMechanism = new PipingFailureMechanism(); - var assessmentSection = mocks.Stub(); - - var stochasticSoilModelCollection = new ObservableCollectionWithSourcePath(); - if (sourcePathSet) - { - stochasticSoilModelCollection.AddRange(Enumerable.Empty(), "some path"); - } - - var nodeData = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection, - pipingFailureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.Stub(); - gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - string expectedToolTip = sourcePathSet - ? RingtoetsPipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_ToolTip - : RingtoetsPipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_ToolTip_No_SourcePath_set; - - TestHelper.AssertContextMenuStripContainsItem(menu, updateStochasticSoilModelsItemIndex, - RingtoetsPipingPluginResources.PipingPlugin_UpdateStochasticSoilModelsMenuItem_Text, - expectedToolTip, - RingtoetsPipingPluginResources.RefreshIcon, - sourcePathSet); - } - } - } - - [Test] - [Apartment(ApartmentState.STA)] - public void ContextMenuStrip_ClickOnUpdateStochasticSoilModelsItemCancelClicked_OpenFileDialogShownCancelMessageLogged() - { - // Setup - const string somePath = "some path"; - using (var treeViewControl = new TreeViewControl()) - { - var pipingFailureMechanism = new PipingFailureMechanism(); - var assessmentSection = mocks.Stub(); - var stochasticSoilModelCollection = new ObservableCollectionWithSourcePath(); - stochasticSoilModelCollection.AddRange(Enumerable.Empty(), somePath); - - var nodeData = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection, - pipingFailureMechanism, - assessmentSection); - - IGui gui = CreateGuiStub(nodeData, treeViewControl); - - plugin.Gui = gui; - - DialogBoxHandler = (name, wnd) => - { - var window = new OpenFileDialogTester(wnd); - window.ClickCancel(); - }; - - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - Action test = () => menu.Items[updateStochasticSoilModelsItemIndex].PerformClick(); - - // Assert - TestHelper.AssertLogMessageIsGenerated( - test, - $"Bijwerken van ondergrondschematisaties in '{somePath}' is door de gebruiker geannuleerd."); - } - } - } - - [Test] - [Apartment(ApartmentState.STA)] - public void ContextMenuStrip_ClickOnUpdateStochasticSoilModelsWithExistingSourceFilePath_SuccessMessageLogged() - { - // Setup - string testDirectory = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, "StochasticSoilModelDatabaseReader"); - string existingFilePath = Path.Combine(testDirectory, "emptyschema.soil"); - - using (var treeViewControl = new TreeViewControl()) - { - var pipingFailureMechanism = new PipingFailureMechanism(); - var assessmentSection = mocks.Stub(); - - var nodeData = new StochasticSoilModelCollectionContext(CreateEmptyImportedStochasticSoilModelCollection(existingFilePath), - pipingFailureMechanism, - assessmentSection); - - IGui gui = CreateGuiStub(nodeData, treeViewControl); - - plugin.Gui = gui; - - DialogBoxHandler = (s, hWnd) => - { - // Activity dialog closes by itself - }; - - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - Action test = () => menu.Items[updateStochasticSoilModelsItemIndex].PerformClick(); - - // Assert - TestHelper.AssertLogMessageIsGenerated( - test, - "Uitvoeren van 'Bijwerken van stochastische ondergrondmodellen.' is gelukt."); - } - } - } - - [Test] - [Apartment(ApartmentState.STA)] - public void ContextMenuStrip_ClickOnUpdateStochasticSoilModelsPathKnownAndConfirmationRequiredAndGiven_SuccessMessageLogged() - { - // Setup - string testDirectory = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, "StochasticSoilModelDatabaseReader"); - string existingFilePath = Path.Combine(testDirectory, "emptyschema.soil"); - - using (var treeViewControl = new TreeViewControl()) - { - var pipingFailureMechanism = new PipingFailureMechanism(); - MakeConfirmationRequired(pipingFailureMechanism); - - var assessmentSection = mocks.Stub(); - - var nodeData = new StochasticSoilModelCollectionContext(CreateEmptyImportedStochasticSoilModelCollection(existingFilePath), - pipingFailureMechanism, - assessmentSection); - - IGui gui = CreateGuiStub(nodeData, treeViewControl); - - plugin.Gui = gui; - - DialogBoxHandler = (name, handler) => - { - DialogBoxHandler = (activityName, activityHandler) => - { - // Activity dialog closes by itself - }; - - var tester = new MessageBoxTester(handler); - tester.ClickOk(); - }; - - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - Action test = () => menu.Items[updateStochasticSoilModelsItemIndex].PerformClick(); - - // Assert - TestHelper.AssertLogMessageIsGenerated( - test, - "Uitvoeren van 'Bijwerken van stochastische ondergrondmodellen.' is gelukt."); - } - } - } - - [Test] - [Apartment(ApartmentState.STA)] - public void ContextMenuStrip_ClickOnUpdateStochasticSoilModelsPathKnownAndConfirmationRequiredButNotGiven_CancelMessageLogged() - { - // Setup - string testDirectory = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, "StochasticSoilModelDatabaseReader"); - string existingFilePath = Path.Combine(testDirectory, "emptyschema.soil"); - - using (var treeViewControl = new TreeViewControl()) - { - var pipingFailureMechanism = new PipingFailureMechanism(); - MakeConfirmationRequired(pipingFailureMechanism); - - var assessmentSection = mocks.Stub(); - - var nodeData = new StochasticSoilModelCollectionContext(CreateEmptyImportedStochasticSoilModelCollection(existingFilePath), - pipingFailureMechanism, - assessmentSection); - - IGui gui = CreateGuiStub(nodeData, treeViewControl); - - plugin.Gui = gui; - - DialogBoxHandler = (name, handler) => - { - var tester = new MessageBoxTester(handler); - tester.ClickCancel(); - }; - - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - Action test = () => menu.Items[updateStochasticSoilModelsItemIndex].PerformClick(); - - // Assert - TestHelper.AssertLogMessageIsGenerated( - test, - $"Bijwerken van ondergrondschematisaties in '{existingFilePath}' is door de gebruiker geannuleerd."); - } - } - } - private static ObservableCollectionWithSourcePath CreateEmptyImportedStochasticSoilModelCollection(string existingFilePath) { var stochasticSoilModelCollection = new ObservableCollectionWithSourcePath(); Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -484,10 +484,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, - exportHandler, + exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -532,10 +534,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -581,10 +585,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -636,10 +642,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -701,10 +709,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -768,10 +778,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -817,10 +829,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -872,10 +886,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -926,11 +942,13 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var mainWindow = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -996,10 +1014,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1046,10 +1066,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1099,10 +1121,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, - exportHandler, + exportHandler, + updateHandler, viewCommands, context, treeViewControl); Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -170,7 +170,7 @@ assessmentSection); // Call - var children = info.ChildNodeObjects(groupContext); + object[] children = info.ChildNodeObjects(groupContext); // Assert CollectionAssert.IsEmpty(children); @@ -195,7 +195,7 @@ assessmentSection); // Call - var children = info.ChildNodeObjects(nodeData).ToArray(); + object[] children = info.ChildNodeObjects(nodeData).ToArray(); // Assert Assert.AreEqual(failureMechanism.WaveConditionsCalculationGroup.Children.Count, children.Length); @@ -227,12 +227,14 @@ var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandler = mocks.StrictMock(); var treeViewControl = mocks.StrictMock(); var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -337,12 +339,14 @@ var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandler = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -441,12 +445,14 @@ var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandler = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -783,7 +789,7 @@ // Assert TestHelper.AssertLogMessages(test, m => { - var messages = m.ToArray(); + string[] messages = m.ToArray(); Assert.AreEqual(4, messages.Length); StringAssert.StartsWith("Validatie van 'A' gestart om: ", messages[0]); StringAssert.StartsWith("Validatie van 'A' beëindigd om: ", messages[1]); @@ -810,8 +816,8 @@ observerB.Expect(o => o.UpdateObserver()); var group = new CalculationGroup(); - var calculationA = GetValidCalculation(); - var calculationB = GetValidCalculation(); + StabilityStoneCoverWaveConditionsCalculation calculationA = GetValidCalculation(); + StabilityStoneCoverWaveConditionsCalculation calculationB = GetValidCalculation(); calculationA.Attach(observerA); calculationB.Attach(observerB); group.Children.Add(calculationA); @@ -853,7 +859,7 @@ // Assert TestHelper.AssertLogMessages(test, m => { - var messages = m.ToArray(); + string[] messages = m.ToArray(); Assert.AreEqual(54, messages.Length); StringAssert.StartsWith("Berekening van 'Nieuwe berekening' gestart om: ", messages[2]); StringAssert.StartsWith("Berekening van 'Nieuwe berekening' beëindigd om: ", messages[25]); @@ -909,7 +915,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - var clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; + ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; // Assert Assert.IsFalse(clearAllOutputItem.Enabled); @@ -929,8 +935,8 @@ failureMechanism, mocks, Path.Combine(hrdPath, "HRD ijsselmeer.sqlite")); var group = new CalculationGroup(); - var calculationA = GetValidCalculation(); - var calculationB = GetValidCalculation(); + StabilityStoneCoverWaveConditionsCalculation calculationA = GetValidCalculation(); + StabilityStoneCoverWaveConditionsCalculation calculationB = GetValidCalculation(); group.Children.Add(calculationA); group.Children.Add(calculationB); @@ -960,7 +966,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - var clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; + ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; // Assert Assert.IsFalse(clearAllOutputItem.Enabled); @@ -989,11 +995,11 @@ } var group = new CalculationGroup(); - var calculationA = GetValidCalculation(); + StabilityStoneCoverWaveConditionsCalculation calculationA = GetValidCalculation(); calculationA.Output = new StabilityStoneCoverWaveConditionsOutput( Enumerable.Empty(), Enumerable.Empty()); - var calculationB = GetValidCalculation(); + StabilityStoneCoverWaveConditionsCalculation calculationB = GetValidCalculation(); calculationB.Output = new StabilityStoneCoverWaveConditionsOutput( Enumerable.Empty(), Enumerable.Empty()); @@ -1101,7 +1107,7 @@ // Assert Assert.AreEqual(2, group.Children.Count); - var newlyAddedItem = group.Children.Last(); + ICalculationBase newlyAddedItem = group.Children.Last(); Assert.IsInstanceOf(newlyAddedItem); Assert.AreEqual("Nieuwe map (1)", newlyAddedItem.Name, "An item with the same name default name already exists, therefore '(1)' needs to be appended."); @@ -1161,9 +1167,7 @@ // When using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick(); - } // Then Assert.AreEqual(2, group.Children.Count); @@ -1221,9 +1225,7 @@ // When using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick(); - } // Then Assert.AreEqual(0, group.Children.Count); @@ -1281,10 +1283,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1331,10 +1335,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 74e4e0c7b938a3c3080ff6b4a09eb01a961fed6a) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -484,10 +484,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -538,10 +540,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -598,10 +602,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -671,10 +677,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -738,10 +746,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -792,10 +802,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -852,10 +864,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -911,11 +925,13 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var mainWindow = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -980,10 +996,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1029,10 +1047,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1081,10 +1101,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r6ce3cfa19ef59b12462bae4a77e9a7ee5a05e28c -r45440093089496f59ed420e772136756c229e30b --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 6ce3cfa19ef59b12462bae4a77e9a7ee5a05e28c) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 45440093089496f59ed420e772136756c229e30b) @@ -171,7 +171,7 @@ assessmentSection); // Call - var children = info.ChildNodeObjects(groupContext); + object[] children = info.ChildNodeObjects(groupContext); // Assert CollectionAssert.IsEmpty(children); @@ -196,7 +196,7 @@ assessmentSection); // Call - var children = info.ChildNodeObjects(nodeData).ToArray(); + object[] children = info.ChildNodeObjects(nodeData).ToArray(); // Assert Assert.AreEqual(failureMechanism.WaveConditionsCalculationGroup.Children.Count, children.Length); @@ -228,12 +228,14 @@ var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandler = mocks.StrictMock(); var treeViewControl = mocks.StrictMock(); var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -338,12 +340,14 @@ var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandler = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -442,12 +446,14 @@ var importHandlerMock = mocks.StrictMock(); var exportHandlerMock = mocks.StrictMock(); exportHandlerMock.Expect(ehm => ehm.CanExportFrom(nodeData)).Return(true); + var updateHandlerMock = mocks.StrictMock(); var viewCommandsHandler = mocks.StrictMock(); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, importHandlerMock, exportHandlerMock, + updateHandlerMock, viewCommandsHandler, nodeData, treeViewControl); @@ -771,7 +777,7 @@ // Assert TestHelper.AssertLogMessages(test, m => { - var messages = m.ToArray(); + string[] messages = m.ToArray(); Assert.AreEqual(4, messages.Length); StringAssert.StartsWith("Validatie van 'A' gestart om: ", messages[0]); StringAssert.StartsWith("Validatie van 'A' beëindigd om: ", messages[1]); @@ -798,8 +804,8 @@ observerB.Expect(o => o.UpdateObserver()); var group = new CalculationGroup(); - var calculationA = GetValidCalculation(); - var calculationB = GetValidCalculation(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationA = GetValidCalculation(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationB = GetValidCalculation(); calculationA.Attach(observerA); calculationB.Attach(observerB); group.Children.Add(calculationA); @@ -841,7 +847,7 @@ // Assert TestHelper.AssertLogMessages(test, m => { - var messages = m.ToArray(); + string[] messages = m.ToArray(); Assert.AreEqual(28, messages.Length); StringAssert.StartsWith("Berekening van 'Nieuwe berekening' gestart om: ", messages[2]); StringAssert.StartsWith("Berekening van 'Nieuwe berekening' beëindigd om: ", messages[12]); @@ -894,7 +900,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - var clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; + ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; // Assert Assert.IsFalse(clearAllOutputItem.Enabled); @@ -913,8 +919,8 @@ failureMechanism, mocks, Path.Combine(hrdPath, "HRD ijsselmeer.sqlite")); var group = new CalculationGroup(); - var calculationA = GetValidCalculation(); - var calculationB = GetValidCalculation(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationA = GetValidCalculation(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationB = GetValidCalculation(); group.Children.Add(calculationA); group.Children.Add(calculationB); @@ -944,7 +950,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - var clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; + ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; // Assert Assert.IsFalse(clearAllOutputItem.Enabled); @@ -973,9 +979,9 @@ } var group = new CalculationGroup(); - var calculationA = GetValidCalculation(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationA = GetValidCalculation(); calculationA.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); - var calculationB = GetValidCalculation(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationB = GetValidCalculation(); calculationB.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); group.Children.Add(calculationA); group.Children.Add(calculationB); @@ -1081,7 +1087,7 @@ // Assert Assert.AreEqual(2, group.Children.Count); - var newlyAddedItem = group.Children.Last(); + ICalculationBase newlyAddedItem = group.Children.Last(); Assert.IsInstanceOf(newlyAddedItem); Assert.AreEqual("Nieuwe map (1)", newlyAddedItem.Name, "An item with the same name default name already exists, therefore '(1)' needs to be appended."); @@ -1140,9 +1146,7 @@ // When using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick(); - } // Then Assert.AreEqual(2, group.Children.Count); @@ -1199,9 +1203,7 @@ // When using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick(); - } // Then Assert.AreEqual(0, group.Children.Count); @@ -1259,10 +1261,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl); @@ -1308,10 +1312,12 @@ var appFeatureCommandHandler = mocks.Stub(); var importHandler = mocks.Stub(); var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); var viewCommands = mocks.Stub(); var menuBuilderMock = new ContextMenuBuilder(appFeatureCommandHandler, importHandler, exportHandler, + updateHandler, viewCommands, context, treeViewControl);