Index: Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs =================================================================== diff -u -r0d01d77a85f997d3cbe2e3f83d6bf3438ec6806d -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs (.../RingtoetsProjectMigrator.cs) (revision 0d01d77a85f997d3cbe2e3f83d6bf3438ec6806d) +++ Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs (.../RingtoetsProjectMigrator.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -108,7 +108,7 @@ ValidateProjectPath(originalFilePath, nameof(originalFilePath), Resources.RingtoetsProjectMigrator_Source_Descriptor); string suggestedFileName = GetSuggestedFileName(originalFilePath); - return inquiryHelper.GetTargetFileLocation(fileFilter, suggestedFileName); + return inquiryHelper.GetTargetFileLocation(fileFilter.Filter, suggestedFileName); } public bool Migrate(string sourceFilePath, string targetFilePath) Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs =================================================================== diff -u -r0ec3500b27a04d8b0d942662301e03d10c277a02 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs (.../RingtoetsProjectMigratorTest.cs) (revision 0ec3500b27a04d8b0d942662301e03d10c277a02) +++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs (.../RingtoetsProjectMigratorTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -265,7 +265,7 @@ var mocks = new MockRepository(); var inquiryHelper = mocks.StrictMock(); - inquiryHelper.Expect(h => h.GetTargetFileLocation(expectedFileFilter, expectedSuggestedFileName)) + inquiryHelper.Expect(h => h.GetTargetFileLocation(expectedFileFilter.Filter, expectedSuggestedFileName)) .Return(expectedReturnPath); mocks.ReplayAll(); Index: Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs =================================================================== diff -u -rfc5dec9b2a89e3593042a84dcc1f2709946b291f -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f) +++ Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -140,7 +140,7 @@ private void ImportItemsUsingDialog(ImportInfo importInfo, object target) { - string fileDialogResult = inquiryHelper.GetSourceFileLocation(importInfo.FileFilterGenerator); + string fileDialogResult = inquiryHelper.GetSourceFileLocation(importInfo.FileFilterGenerator.Filter); if (fileDialogResult != null && importInfo.VerifyUpdates(target)) { Index: Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs =================================================================== diff -u -rfc5dec9b2a89e3593042a84dcc1f2709946b291f -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs (.../GuiUpdateHandler.cs) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f) +++ Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs (.../GuiUpdateHandler.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -144,7 +144,7 @@ string filePath = oldPath; if (!File.Exists(filePath)) { - filePath = inquiryHelper.GetSourceFileLocation(updateInfo.FileFilterGenerator); + filePath = inquiryHelper.GetSourceFileLocation(updateInfo.FileFilterGenerator.Filter); } if (filePath != null && updateInfo.VerifyUpdates(target)) { Index: Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs =================================================================== diff -u -r2e82c6e72a3c33965987f82c6edc03566d633eaf -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision 2e82c6e72a3c33965987f82c6edc03566d633eaf) +++ Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -44,6 +44,7 @@ private readonly IStoreProject projectPersistor; private readonly IProjectFactory projectFactory; private readonly IMigrateProject projectMigrator; + private readonly IInquiryHelper inquiryHelper; /// /// Initializes a new instance of the class. @@ -52,15 +53,15 @@ /// Class responsible for the migration of the application projects. /// The factory to use when creating new projects. /// The class owning the application project. + /// The object facilitating user interaction. /// Controller for UI. - public StorageCommandHandler(IStoreProject projectStorage, - IMigrateProject projectMigrator, - IProjectFactory projectFactory, - IProjectOwner projectOwner, - IWin32Window dialogParent) + public StorageCommandHandler(IStoreProject projectStorage, IMigrateProject projectMigrator, + IProjectFactory projectFactory, IProjectOwner projectOwner, + IInquiryHelper inquiryHelper, IWin32Window dialogParent) { this.dialogParent = dialogParent; this.projectOwner = projectOwner; + this.inquiryHelper = inquiryHelper; projectPersistor = projectStorage; this.projectMigrator = projectMigrator; this.projectFactory = projectFactory; @@ -271,22 +272,19 @@ private bool ShowSaveUnsavedChangesDialog() { - var confirmation = MessageBox.Show( - string.Format(CultureInfo.CurrentCulture, - Resources.StorageCommandHandler_OpenSaveOrDiscardProjectDialog_SaveChangesToProject_0, - projectOwner.Project.Name), - Resources.StorageCommandHandler_ClosingProject_Title, - MessageBoxButtons.YesNoCancel); + string inquiry = string.Format(CultureInfo.CurrentCulture, + Resources.StorageCommandHandler_OpenSaveOrDiscardProjectDialog_SaveChangesToProject_0, + projectOwner.Project.Name); + OptionalStepResult confirmation = inquiryHelper.InquirePerformOptionalStep(Resources.StorageCommandHandler_ClosingProject_Title, + inquiry); switch (confirmation) { - case DialogResult.Cancel: + case OptionalStepResult.Cancel: return false; - case DialogResult.Yes: + case OptionalStepResult.PerformOptionalStep: ReleaseDatabaseFileHandle(); return SaveProject(); - case DialogResult.No: - break; } return true; } @@ -304,20 +302,12 @@ /// The selected project file, or null otherwise. private string OpenProjectSaveFileDialog(string projectName) { - using (var saveFileDialog = new SaveFileDialog + string filePath = inquiryHelper.GetTargetFileLocation(projectPersistor.FileFilter, projectName); + if (filePath == null) { - Title = Resources.SaveFileDialog_Title, - Filter = projectPersistor.FileFilter, - FileName = projectName - }) - { - if (saveFileDialog.ShowDialog() != DialogResult.OK) - { - log.Info(Resources.StorageCommandHandler_SaveProject_Saving_project_canceled); - return null; - } - return saveFileDialog.FileName; + log.Info(Resources.StorageCommandHandler_SaveProject_Saving_project_canceled); } + return filePath; } } } \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj =================================================================== diff -u -r82b198560cfaa4d3e1d882dca9fd7859f169554e -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 82b198560cfaa4d3e1d882dca9fd7859f169554e) +++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -145,6 +145,7 @@ + Index: Core/Common/src/Core.Common.Gui/DialogBasedInquiryHelper.cs =================================================================== diff -u -r206804512fc341a06a08565ee0a9711768079ed9 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/src/Core.Common.Gui/DialogBasedInquiryHelper.cs (.../DialogBasedInquiryHelper.cs) (revision 206804512fc341a06a08565ee0a9711768079ed9) +++ Core/Common/src/Core.Common.Gui/DialogBasedInquiryHelper.cs (.../DialogBasedInquiryHelper.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -51,17 +51,17 @@ public string GetSourceFileLocation() { - return GetSourceFileLocation(new FileFilterGenerator()); + return GetSourceFileLocation(new FileFilterGenerator().Filter); } - public string GetSourceFileLocation(FileFilterGenerator filter) + public string GetSourceFileLocation(string fileFilter) { string filePath = null; using (var dialog = new OpenFileDialog { Multiselect = false, Title = Resources.OpenFileDialog_Title, - Filter = filter.Filter + Filter = fileFilter }) { DialogResult result = dialog.ShowDialog(dialogParent); @@ -75,16 +75,16 @@ public string GetTargetFileLocation() { - return GetTargetFileLocation(new FileFilterGenerator(), null); + return GetTargetFileLocation(new FileFilterGenerator().Filter, null); } - public string GetTargetFileLocation(FileFilterGenerator filter, string suggestedFileName) + public string GetTargetFileLocation(string fileFilter, string suggestedFileName) { string filePath = null; using (var dialog = new SaveFileDialog { Title = Resources.SaveFileDialog_Title, - Filter = filter.Filter, + Filter = fileFilter, FileName = suggestedFileName }) { @@ -100,11 +100,31 @@ public bool InquireContinuation(string query) { DialogResult dialog = MessageBox.Show( - dialogParent, - query, - CoreCommonBaseResources.Confirm, + dialogParent, + query, + CoreCommonBaseResources.Confirm, MessageBoxButtons.OKCancel); return dialog == DialogResult.OK; } + + public OptionalStepResult InquirePerformOptionalStep(string workflowDescription, string query) + { + DialogResult confirmation = MessageBox.Show(dialogParent, + query, + workflowDescription, + MessageBoxButtons.YesNoCancel); + + switch (confirmation) + { + case DialogResult.Cancel: + return OptionalStepResult.Cancel; + case DialogResult.Yes: + return OptionalStepResult.PerformOptionalStep; + case DialogResult.No: + return OptionalStepResult.SkipOptionalStep; + default: + throw new NotImplementedException("Dialogbox should only return the above values."); + } + } } } \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/GuiCore.cs =================================================================== diff -u -r7963bd77ea5540754906c7e994f2687e33a89dde -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 7963bd77ea5540754906c7e994f2687e33a89dde) +++ Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -123,7 +123,8 @@ viewCommandHandler = new ViewCommandHandler(this, this, this); - StorageCommands = new StorageCommandHandler(projectStore, projectMigrator, projectFactory, this, MainWindow); + StorageCommands = new StorageCommandHandler(projectStore, projectMigrator, projectFactory, + this, dialogBasedInquiryHelper, MainWindow); importCommandHandler = new GuiImportHandler(MainWindow, Plugins.SelectMany(p => p.GetImportInfos()), dialogBasedInquiryHelper); exportCommandHandler = new GuiExportHandler(MainWindow, Plugins.SelectMany(p => p.GetExportInfos())); Index: Core/Common/src/Core.Common.Gui/IInquiryHelper.cs =================================================================== diff -u -r206804512fc341a06a08565ee0a9711768079ed9 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/src/Core.Common.Gui/IInquiryHelper.cs (.../IInquiryHelper.cs) (revision 206804512fc341a06a08565ee0a9711768079ed9) +++ Core/Common/src/Core.Common.Gui/IInquiryHelper.cs (.../IInquiryHelper.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -36,9 +36,9 @@ /// /// Returns the path of an existing file that the user has chosen. /// - /// A filter to which the path returned complies. + /// A filter to which the path returned complies. /// A file location, or null if no location was chosen. - string GetSourceFileLocation(FileFilterGenerator filter); + string GetSourceFileLocation(string fileFilter); /// /// Returns the path to a file, which may or may not exist yet, that the user has chosen. @@ -50,17 +50,27 @@ /// /// Returns the path to a file, which may or may not exist yet, that the user has chosen. /// - /// A filter to which the path returned complies. + /// A filter to which the path returned complies. /// The initial name the user can choose. /// A path to a file, which may or may not exist yet, or null if no location /// was chosen. - string GetTargetFileLocation(FileFilterGenerator filter, string suggestedName); + string GetTargetFileLocation(string fileFilter, string suggestedName); /// /// 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); + + /// + /// Checks with the user if a certain optional step in some workflow should be + /// performed or not. + /// + /// The short descriptive text on the workflow + /// currently being performed. + /// The query to which the user needs to answer. + /// How the workflow should continue. + OptionalStepResult InquirePerformOptionalStep(string workflowDescription, string query); } } \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/OptionalStepResult.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/OptionalStepResult.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/OptionalStepResult.cs (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -0,0 +1,44 @@ +// 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 +{ + /// + /// Indicates how an optional step in some workflow should be handled. + /// + public enum OptionalStepResult + { + /// + /// The optional step should be executed. + /// + PerformOptionalStep, + + /// + /// The optional step should be skipped. + /// + SkipOptionalStep, + + /// + /// Cancel the whole workflow. + /// + Cancel + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Commands/GuiImportHandlerTest.cs =================================================================== diff -u -r199f41a71b3b4c214f819f4519fffd4dc9418ff9 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/test/Core.Common.Gui.Test/Commands/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision 199f41a71b3b4c214f819f4519fffd4dc9418ff9) +++ Core/Common/test/Core.Common.Gui.Test/Commands/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -292,7 +292,7 @@ var mockRepository = new MockRepository(); var inquiryHelper = mockRepository.Stub(); - inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator)).Return(filePath); + inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator.Filter)).Return(filePath); var fileImporter = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -349,7 +349,7 @@ var mockRepository = new MockRepository(); var inquiryHelper = mockRepository.Stub(); - inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator)).Return(null); + inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator.Filter)).Return(null); var fileImporter = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -387,7 +387,7 @@ var mockRepository = new MockRepository(); var inquiryHelper = mockRepository.Stub(); - inquiryHelper.Stub(ih => ih.GetSourceFileLocation(generator)).Return("/some/path"); + inquiryHelper.Stub(ih => ih.GetSourceFileLocation(generator.Filter)).Return("/some/path"); var fileImporter = mockRepository.Stub(); mockRepository.ReplayAll(); Index: Core/Common/test/Core.Common.Gui.Test/Commands/GuiUpdateHandlerTest.cs =================================================================== diff -u -r199f41a71b3b4c214f819f4519fffd4dc9418ff9 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/test/Core.Common.Gui.Test/Commands/GuiUpdateHandlerTest.cs (.../GuiUpdateHandlerTest.cs) (revision 199f41a71b3b4c214f819f4519fffd4dc9418ff9) +++ Core/Common/test/Core.Common.Gui.Test/Commands/GuiUpdateHandlerTest.cs (.../GuiUpdateHandlerTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -292,7 +292,7 @@ var mockRepository = new MockRepository(); var inquiryHelper = mockRepository.Stub(); - inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator)).Return(filePath); + inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator.Filter)).Return(filePath); var fileImporter = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -349,7 +349,7 @@ var mockRepository = new MockRepository(); var inquiryHelper = mockRepository.Stub(); - inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator)).Return(null); + inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator.Filter)).Return(null); var fileImporter = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -386,7 +386,7 @@ var targetObject = new object(); var mockRepository = new MockRepository(); var inquiryHelper = mockRepository.Stub(); - inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator)).Return("/some/path"); + inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator.Filter)).Return("/some/path"); var fileImporter = mockRepository.Stub(); mockRepository.ReplayAll(); Index: Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs =================================================================== diff -u -r9cc432c888ba65a44c2017f6f62ec95a77cd0bd0 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision 9cc432c888ba65a44c2017f6f62ec95a77cd0bd0) +++ Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -62,6 +62,7 @@ projectFactory.Stub(pf => pf.CreateNewProject()).Return(newProject); projectOwner.Expect(po => po.SetProject(newProject, null)); + var inquiryHelper = mocks.Stub(); var mainWindowController = mocks.Stub(); mocks.ReplayAll(); @@ -71,6 +72,7 @@ projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); // Call @@ -111,13 +113,16 @@ var projectOwner = mocks.Stub(); projectOwner.Stub(po => po.Project).Return(projectStub); projectOwner.Stub(po => po.ProjectFilePath).Return(someValidFilePath); + + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (s, hWnd) => @@ -162,13 +167,16 @@ var projectOwner = mocks.Stub(); projectOwner.Stub(po => po.Project).Return(projectStub); projectOwner.Stub(po => po.ProjectFilePath).Return(someValidFilePath); + + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (s, hWnd) => @@ -215,13 +223,16 @@ var projectOwner = mocks.Stub(); projectOwner.Stub(po => po.SetProject(loadedProject, pathToMigratedFile)); + + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (name, wnd) => @@ -268,13 +279,15 @@ .Repeat.Never(); var mainWindowController = mocks.Stub(); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); // Call @@ -320,13 +333,15 @@ .Repeat.Never(); var mainWindowController = mocks.Stub(); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); // Call @@ -367,13 +382,15 @@ projectOwner.Stub(po => po.SetProject(project, null)); var mainWindowController = mocks.Stub(); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); // Call @@ -419,13 +436,15 @@ projectOwner.Expect(po => po.SetProject(project, null)); var mainWindowController = mocks.Stub(); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); // Call @@ -474,13 +493,15 @@ projectOwner.Expect(po => po.SetProject(project, null)); var mainWindowController = mocks.Stub(); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (name, wnd) => @@ -524,13 +545,15 @@ var projectOwner = mocks.Stub(); projectOwner.Stub(po => po.Project).Return(project); projectOwner.Stub(po => po.SetProject(project, null)); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (name, wnd) => @@ -575,13 +598,16 @@ var projectOwner = mocks.Stub(); projectOwner.Stub(po => po.Project).Return(project); projectOwner.Stub(po => po.SetProject(project, null)); + + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (name, wnd) => @@ -624,13 +650,16 @@ var projectOwner = mocks.Stub(); projectOwner.Stub(po => po.SetProject(loadedProject, pathToSomeValidFile)); + + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (name, wnd) => @@ -681,13 +710,15 @@ projectOwner.Stub(po => po.ProjectFilePath).Return(""); projectOwner.Stub(po => po.SetProject(loadedProject, pathToSomeValidFile)); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (name, wnd) => @@ -728,6 +759,7 @@ projectStorage.Stub(ps => ps.HasStagedProjectChanges(null)).IgnoreArguments().Return(false); projectStorage.Stub(ps => ps.FileFilter).Return(string.Empty); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); string projectPath = TestHelper.GetScratchPadPath( @@ -739,6 +771,7 @@ projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (name, wnd) => @@ -765,13 +798,15 @@ var projectStorage = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectOwner = mocks.Stub(); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); DialogBoxHandler = (name, wnd) => @@ -804,13 +839,15 @@ var projectOwner = mocks.Stub(); projectOwner.Stub(po => po.Project).Return(project); projectOwner.Stub(po => po.ProjectFilePath).Return(""); + var inquiryHelper = mocks.Stub(); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwner, + inquiryHelper, mainWindowController); // Call @@ -845,33 +882,28 @@ var projectOwnerStub = mocks.Stub(); projectOwnerStub.Stub(po => po.Project).Return(project); projectOwnerStub.Stub(po => po.ProjectFilePath).Return(""); + + var inquiryHelper = mocks.StrictMock(); + inquiryHelper.Expect(h => h.InquirePerformOptionalStep("Project aan het sluiten...", + $"Sla wijzigingen in het project op: {projectName}?")). + Return(OptionalStepResult.Cancel); mocks.ReplayAll(); - string messageBoxText = null; - string expectedMessage = $"Sla wijzigingen in het project op: {projectName}?"; - var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwnerStub, + inquiryHelper, mainWindowController); - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - messageBoxText = helper.Text; - helper.ClickCancel(); - }; - // Call bool changesHandled = storageCommandHandler.HandleUnsavedChanges(); // Assert Assert.IsFalse(changesHandled); mocks.VerifyAll(); - Assert.AreEqual(expectedMessage, messageBoxText); } [Test] @@ -897,33 +929,28 @@ var projectOwnerStub = mocks.Stub(); projectOwnerStub.Stub(po => po.Project).Return(project); projectOwnerStub.Stub(po => po.ProjectFilePath).Return(""); + + var inquiryHelper = mocks.StrictMock(); + inquiryHelper.Expect(h => h.InquirePerformOptionalStep("Project aan het sluiten...", + $"Sla wijzigingen in het project op: {projectName}?")) + .Return(OptionalStepResult.SkipOptionalStep); mocks.ReplayAll(); - string messageBoxText = null; - string expectedMessage = $"Sla wijzigingen in het project op: {projectName}?"; - var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwnerStub, + inquiryHelper, mainWindowController); - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - messageBoxText = helper.Text; - helper.SendCommand(MessageBoxTester.Command.No); - }; - // Call bool changesHandled = storageCommandHandler.HandleUnsavedChanges(); // Assert Assert.IsTrue(changesHandled); mocks.VerifyAll(); - Assert.AreEqual(expectedMessage, messageBoxText); } [Test] @@ -932,7 +959,6 @@ { // Setup const string projectName = "Project"; - string messageBoxText = null; string someValidFilePath = TestHelper.GetScratchPadPath(nameof(AskConfirmationUnsavedChanges_ProjectSetWithChangeYesPressed_ReturnsTrue)); using (new FileDisposeHelper(someValidFilePath)) { @@ -954,25 +980,24 @@ var projectOwnerStub = mocks.Stub(); projectOwnerStub.Stub(po => po.Project).Return(project); projectOwnerStub.Stub(po => po.ProjectFilePath).Return(someValidFilePath); + + var inquiryHelper = mocks.StrictMock(); + inquiryHelper.Expect(h => h.InquirePerformOptionalStep("Project aan het sluiten...", + $"Sla wijzigingen in het project op: {projectName}?")) + .Return(OptionalStepResult.PerformOptionalStep); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwnerStub, + inquiryHelper, mainWindowController); - DialogBoxHandler = (name, wnd) => + DialogBoxHandler = (s, hWnd) => { - var helper = new MessageBoxTester(wnd); - messageBoxText = helper.Text; - helper.SendCommand(MessageBoxTester.Command.Yes); - - DialogBoxHandler = (s, hWnd) => - { - // Expect progress dialog, which will close automatically. - }; + // Expect progress dialog, which will close automatically. }; // Call @@ -983,17 +1008,15 @@ } mocks.VerifyAll(); - string expectedMessage = $"Sla wijzigingen in het project op: {projectName}?"; - Assert.AreEqual(expectedMessage, messageBoxText); } [Test] [Apartment(ApartmentState.STA)] public void AskConfirmationUnsavedChanges_ProjectSetWithChangeYesFileDoesNotExist_ReturnsTrue() { // Setup + const string fileFilter = " | *.rtd"; const string projectName = "Project"; - string messageBoxText = null; string someValidFilePath = TestHelper.GetScratchPadPath(nameof(AskConfirmationUnsavedChanges_ProjectSetWithChangeYesFileDoesNotExist_ReturnsTrue)); var mainWindowController = mocks.Stub(); @@ -1007,7 +1030,7 @@ projectStorage.Stub(ps => ps.HasStagedProject).Return(true); projectStorage.Expect(ps => ps.HasStagedProjectChanges(someValidFilePath)).Return(true); projectStorage.Expect(ps => ps.UnstageProject()); - projectStorage.Stub(ps => ps.FileFilter).Return(string.Empty); + projectStorage.Stub(ps => ps.FileFilter).Return(fileFilter); projectStorage.Expect(p => p.SaveProjectAs(someValidFilePath)); var projectMigrator = mocks.Stub(); @@ -1016,31 +1039,26 @@ projectOwnerStub.Stub(po => po.Project).Return(project); projectOwnerStub.Stub(po => po.ProjectFilePath).Return(someValidFilePath); projectOwnerStub.Expect(po => po.SetProject(project, someValidFilePath)); + + var inquiryHelper = mocks.StrictMock(); + inquiryHelper.Expect(h => h.InquirePerformOptionalStep("Project aan het sluiten...", + $"Sla wijzigingen in het project op: {projectName}?")) + .Return(OptionalStepResult.PerformOptionalStep); + inquiryHelper.Expect(h => h.GetTargetFileLocation(fileFilter, projectName)) + .Return(someValidFilePath); mocks.ReplayAll(); var storageCommandHandler = new StorageCommandHandler( projectStorage, projectMigrator, projectFactory, projectOwnerStub, + inquiryHelper, mainWindowController); - DialogBoxHandler = (name, wnd) => + DialogBoxHandler = (s, hWnd) => { - var messageBox = new MessageBoxTester(wnd); - messageBoxText = messageBox.Text; - messageBox.SendCommand(MessageBoxTester.Command.Yes); - - ModalFormHandler = (modalName, modalWnd, form) => - { - var saveFileDialog = new SaveFileDialogTester(modalWnd); - saveFileDialog.SaveFile(someValidFilePath); - - DialogBoxHandler = (s, hWnd) => - { - // Expect progress dialog, which will close automatically. - }; - }; + // Expect progress dialog, which will close automatically. }; // Call @@ -1050,8 +1068,6 @@ Assert.IsTrue(changesHandled); mocks.VerifyAll(); - string expectedMessage = $"Sla wijzigingen in het project op: {projectName}?"; - Assert.AreEqual(expectedMessage, messageBoxText); } } } \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/DialogBasedInquiryHelperTest.cs =================================================================== diff -u -r206804512fc341a06a08565ee0a9711768079ed9 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Core/Common/test/Core.Common.Gui.Test/DialogBasedInquiryHelperTest.cs (.../DialogBasedInquiryHelperTest.cs) (revision 206804512fc341a06a08565ee0a9711768079ed9) +++ Core/Common/test/Core.Common.Gui.Test/DialogBasedInquiryHelperTest.cs (.../DialogBasedInquiryHelperTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -258,6 +258,56 @@ Assert.AreEqual(confirm, result); } + [Test] + [TestCase(DialogResult.Cancel, OptionalStepResult.Cancel)] + [TestCase(DialogResult.Yes, OptionalStepResult.PerformOptionalStep)] + [TestCase(DialogResult.No, OptionalStepResult.SkipOptionalStep)] + public void InquirePerformOptionalStep_VariousScenarios_ReturnExpectedValue(DialogResult clickedResult, + OptionalStepResult expectedResult) + { + // Setup + dialogParent.Expect(d => d.Handle).Repeat.AtLeastOnce().Return(default(IntPtr)); + mocks.ReplayAll(); + + var helper = new DialogBasedInquiryHelper(dialogParent); + + string actualQuery = null; + string title = null; + + DialogBoxHandler = (name, wnd) => + { + var tester = new MessageBoxTester(wnd); + actualQuery = tester.Text; + title = tester.Title; + + switch (clickedResult) + { + case DialogResult.Yes: + tester.SendCommand(MessageBoxTester.Command.Yes); + break; + case DialogResult.No: + tester.SendCommand(MessageBoxTester.Command.No); + break; + case DialogResult.Cancel: + tester.SendCommand(MessageBoxTester.Command.Cancel); + break; + } + }; + + const string description = "A"; + const string query = "B"; + + // Call + OptionalStepResult result = helper.InquirePerformOptionalStep(description, query); + + // Assert + Assert.AreEqual(expectedResult, result); + + Assert.AreEqual(description, title); + Assert.AreEqual(query, actualQuery); + mocks.VerifyAll(); + } + public override void TearDown() { mocks.VerifyAll(); Index: Ringtoets/Common/src/Ringtoets.Common.IO/Writers/CalculationConfigurationWriter.cs =================================================================== diff -u -rfde0ecf7d1d897337907d512aab471ead4a4c5e4 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Ringtoets/Common/src/Ringtoets.Common.IO/Writers/CalculationConfigurationWriter.cs (.../CalculationConfigurationWriter.cs) (revision fde0ecf7d1d897337907d512aab471ead4a4c5e4) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Writers/CalculationConfigurationWriter.cs (.../CalculationConfigurationWriter.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Xml; using Core.Common.IO.Exceptions; using Core.Common.Utils.Properties; @@ -92,26 +91,24 @@ /// /// Writes the in XML format to file. /// - /// The distributions, as tuples of name and distribution, to write. + /// The dictionary of distributions, keyed on name, to write. /// The writer to use for writing. /// Thrown when is null. /// Thrown when the is closed. - protected static void WriteDistributions(IEnumerable> distributions, XmlWriter writer) + protected static void WriteDistributions(IDictionary distributions, XmlWriter writer) { if (distributions == null) { throw new ArgumentNullException(nameof(distributions)); } - Tuple[] disributionArray = distributions.ToArray(); - - if (disributionArray.Any()) + if (distributions.Count > 0) { writer.WriteStartElement(ConfigurationSchemaIdentifiers.StochastsElement); - foreach (Tuple distribution in disributionArray) + foreach (KeyValuePair keyValuePair in distributions) { - WriteDistribution(distribution.Item2, distribution.Item1, writer); + WriteDistribution(keyValuePair.Value, keyValuePair.Key, writer); } writer.WriteEndElement(); Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/CalculationConfigurationWriterTest.cs =================================================================== diff -u -rfde0ecf7d1d897337907d512aab471ead4a4c5e4 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/CalculationConfigurationWriterTest.cs (.../CalculationConfigurationWriterTest.cs) (revision fde0ecf7d1d897337907d512aab471ead4a4c5e4) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/CalculationConfigurationWriterTest.cs (.../CalculationConfigurationWriterTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -142,12 +142,8 @@ try { - using (XmlWriter xmlWriter = XmlWriter.Create(filePath, new XmlWriterSettings + using (XmlWriter xmlWriter = CreateXmlWriter(filePath)) { - Indent = true, - ConformanceLevel = ConformanceLevel.Fragment - })) - { var writer = new SimpleCalculationConfigurationWriter(); // Call @@ -173,16 +169,12 @@ try { - using (XmlWriter xmlWriter = XmlWriter.Create(filePath, new XmlWriterSettings + using (XmlWriter xmlWriter = CreateXmlWriter(filePath)) { - Indent = true, - ConformanceLevel = ConformanceLevel.Fragment - })) - { var writer = new SimpleCalculationConfigurationWriter(); // Call - writer.PublicWriteDistributions(Enumerable.Empty>(), xmlWriter); + writer.PublicWriteDistributions(new Dictionary(), xmlWriter); } // Assert @@ -205,28 +197,28 @@ TestDataPath.Ringtoets.Common.IO, Path.Combine(nameof(CalculationConfigurationWriter), "distributions.xml")); - var distributions = new List> + var distributions = new Dictionary { - new Tuple("normal", new NormalDistribution { - Mean = (RoundedDouble) 0.2, - StandardDeviation = (RoundedDouble) 0.1 - }), - new Tuple("lognormal", new LogNormalDistribution + "normal", new NormalDistribution + { + Mean = (RoundedDouble) 0.2, + StandardDeviation = (RoundedDouble) 0.1 + } + }, { - Mean = (RoundedDouble) 0.4, - StandardDeviation = (RoundedDouble) 0.3 - }) + "lognormal", new LogNormalDistribution + { + Mean = (RoundedDouble) 0.4, + StandardDeviation = (RoundedDouble) 0.3 + } + } }; try { - using (XmlWriter xmlWriter = XmlWriter.Create(filePath, new XmlWriterSettings + using (XmlWriter xmlWriter = CreateXmlWriter(filePath)) { - Indent = true, - ConformanceLevel = ConformanceLevel.Fragment - })) - { var writer = new SimpleCalculationConfigurationWriter(); // Call @@ -254,12 +246,8 @@ try { - using (XmlWriter xmlWriter = XmlWriter.Create(filePath, new XmlWriterSettings + using (XmlWriter xmlWriter = CreateXmlWriter(filePath)) { - Indent = true, - ConformanceLevel = ConformanceLevel.Fragment - })) - { var writer = new SimpleCalculationConfigurationWriter(); // Call @@ -298,12 +286,8 @@ try { - using (XmlWriter xmlWriter = XmlWriter.Create(filePath, new XmlWriterSettings + using (XmlWriter xmlWriter = CreateXmlWriter(filePath)) { - Indent = true, - ConformanceLevel = ConformanceLevel.Fragment - })) - { var writer = new SimpleCalculationConfigurationWriter(); // Call @@ -382,11 +366,20 @@ } } + private static XmlWriter CreateXmlWriter(string filePath) + { + return XmlWriter.Create(filePath, new XmlWriterSettings + { + Indent = true, + ConformanceLevel = ConformanceLevel.Fragment + }); + } + public class SimpleCalculationConfigurationWriter : CalculationConfigurationWriter { public const string CalculationElementTag = "calculation"; - public void PublicWriteDistributions(IEnumerable> distributions, XmlWriter writer) + public void PublicWriteDistributions(IDictionary distributions, XmlWriter writer) { WriteDistributions(distributions, writer); } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/GrassCoverErosionInwardsConfigurationWriter.cs =================================================================== diff -u -r2923096aeb41e1fb5d4ba0ad43ccb9f95ca7407a -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/GrassCoverErosionInwardsConfigurationWriter.cs (.../GrassCoverErosionInwardsConfigurationWriter.cs) (revision 2923096aeb41e1fb5d4ba0ad43ccb9f95ca7407a) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/GrassCoverErosionInwardsConfigurationWriter.cs (.../GrassCoverErosionInwardsConfigurationWriter.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using System.Xml; using Ringtoets.Common.Data.Probabilistics; @@ -30,10 +29,10 @@ namespace Ringtoets.GrassCoverErosionInwards.IO { /// - /// Writer for writing a piping configuration to XML. + /// Writer for writing a grass cover erosion inwards configuration to XML. /// - public class GrassCoverErosionInwardsConfigurationWriter : CalculationConfigurationWriter { - + public class GrassCoverErosionInwardsConfigurationWriter : CalculationConfigurationWriter + { protected override void WriteCalculation(GrassCoverErosionInwardsCalculation calculation, XmlWriter writer) { writer.WriteStartElement(ConfigurationSchemaIdentifiers.CalculationElement); @@ -63,11 +62,15 @@ writer.WriteEndElement(); } - private static IEnumerable> CreateInputDistributions(GrassCoverErosionInwardsInput calculationInputParameters) + private static IDictionary CreateInputDistributions(GrassCoverErosionInwardsInput calculationInputParameters) { - yield return Tuple.Create( - GrassCoverErosionInwardsConfigurationSchemaIdentifiers.CriticalFlowRateStochastName, - calculationInputParameters.CriticalFlowRate); + return new Dictionary + { + { + GrassCoverErosionInwardsConfigurationSchemaIdentifiers.CriticalFlowRateStochastName, + calculationInputParameters.CriticalFlowRate + } + }; } private static void WriteWaveReduction(GrassCoverErosionInwardsInput input, XmlWriter writer) Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/GrassCoverErosionInwardsConfigurationWriterTest.cs =================================================================== diff -u -r020439f88aaed9dd51967acbc8518f37c95791d1 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/GrassCoverErosionInwardsConfigurationWriterTest.cs (.../GrassCoverErosionInwardsConfigurationWriterTest.cs) (revision 020439f88aaed9dd51967acbc8518f37c95791d1) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/GrassCoverErosionInwardsConfigurationWriterTest.cs (.../GrassCoverErosionInwardsConfigurationWriterTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.AccessControl; @@ -38,14 +37,6 @@ [TestFixture] public class GrassCoverErosionInwardsConfigurationWriterTest { - private static IEnumerable Calculations - { - get - { - yield break; - } - } - [Test] public void Write_ConfigurationNull_ThrowArgumentNullException() { @@ -187,7 +178,7 @@ TestDataPath.Ringtoets.GrassCoverErosionInwards.IO, Path.Combine(nameof(GrassCoverErosionInwardsConfigurationWriter), "completeConfiguration.xml")); - var calculation = CreateCompleteCalculation(); + GrassCoverErosionInwardsCalculation calculation = CreateCompleteCalculation(); try { Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ExportInfos/GrassCoverErosionInwardsCalculationContextExportInfoTest.cs =================================================================== diff -u -rea2a8559c7e3aa4fbb0379beade52581280064f2 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ExportInfos/GrassCoverErosionInwardsCalculationContextExportInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextExportInfoTest.cs) (revision ea2a8559c7e3aa4fbb0379beade52581280064f2) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ExportInfos/GrassCoverErosionInwardsCalculationContextExportInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextExportInfoTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -35,7 +35,6 @@ [TestFixture] public class GrassCoverErosionInwardsCalculationContextExportInfoTest { - [Test] public void Initialized_Always_ExpectedPropertiesSet() { @@ -64,8 +63,8 @@ mocks.ReplayAll(); var context = new GrassCoverErosionInwardsCalculationContext(new GrassCoverErosionInwardsCalculation(), - new GrassCoverErosionInwardsFailureMechanism(), - assessmentSection); + new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); using (var plugin = new GrassCoverErosionInwardsPlugin()) { @@ -104,9 +103,9 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var context = new GrassCoverErosionInwardsCalculationContext(new GrassCoverErosionInwardsCalculation(), - new GrassCoverErosionInwardsFailureMechanism(), - assessmentSection); + var context = new GrassCoverErosionInwardsCalculationContext(new GrassCoverErosionInwardsCalculation(), + new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); using (var plugin = new GrassCoverErosionInwardsPlugin()) { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingConfigurationWriter.cs =================================================================== diff -u -r5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingConfigurationWriter.cs (.../PipingConfigurationWriter.cs) (revision 5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Exporters/PipingConfigurationWriter.cs (.../PipingConfigurationWriter.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using System.Xml; using Ringtoets.Common.Data.Probabilistics; @@ -80,15 +79,19 @@ writer.WriteEndElement(); } - private static IEnumerable> CreateInputDistributions(PipingInput calculationInputParameters) + private static IDictionary CreateInputDistributions(PipingInput calculationInputParameters) { - yield return Tuple.Create( - PipingConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName, - calculationInputParameters.PhreaticLevelExit); - - yield return Tuple.Create( - PipingConfigurationSchemaIdentifiers.DampingFactorExitStochastName, - calculationInputParameters.DampingFactorExit); + return new Dictionary + { + { + PipingConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName, + calculationInputParameters.PhreaticLevelExit + }, + { + PipingConfigurationSchemaIdentifiers.DampingFactorExitStochastName, + calculationInputParameters.DampingFactorExit + } + }; } } } \ No newline at end of file Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsInputConfigurationWriterTest.cs =================================================================== diff -u -r2923096aeb41e1fb5d4ba0ad43ccb9f95ca7407a -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsInputConfigurationWriterTest.cs (.../WaveConditionsInputConfigurationWriterTest.cs) (revision 2923096aeb41e1fb5d4ba0ad43ccb9f95ca7407a) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditionsInputConfigurationWriterTest.cs (.../WaveConditionsInputConfigurationWriterTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.IO; using System.Xml; using Core.Common.Base; @@ -65,11 +66,8 @@ try { - using (XmlWriter xmlWriter = XmlWriter.Create(filePath, new XmlWriterSettings + using (XmlWriter xmlWriter = CreateXmlWriter(filePath)) { - Indent = true - })) - { var writer = new SimpleWaveConditionsInputConfigurationWriter(); // Call @@ -102,7 +100,7 @@ var calculation = new SimpleWaveConditionsCalculation { Name = "Berekening 1", - Input = + Input = { HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Locatie1"), UpperBoundaryRevetment = (RoundedDouble) 1.5, @@ -124,11 +122,8 @@ try { - using (XmlWriter xmlWriter = XmlWriter.Create(filePath, new XmlWriterSettings + using (XmlWriter xmlWriter = CreateXmlWriter(filePath)) { - Indent = true - })) - { var writer = new SimpleWaveConditionsInputConfigurationWriter(); // Call @@ -146,32 +141,39 @@ File.Delete(filePath); } } + + private static XmlWriter CreateXmlWriter(string filePath) + { + return XmlWriter.Create(filePath, new XmlWriterSettings + { + Indent = true + }); + } } public class SimpleWaveConditionsInputConfigurationWriter : WaveConditionsInputConfigurationWriter { - protected override void WriteCalculation(SimpleWaveConditionsCalculation calculation, XmlWriter writer) + public void PublicWriteCalculation(SimpleWaveConditionsCalculation calculation, XmlWriter writer) { - WriteCalculation(calculation.Name, calculation.Input, writer); + WriteCalculation(calculation, writer); } - public void PublicWriteCalculation(SimpleWaveConditionsCalculation calculation, XmlWriter writer) + protected override void WriteCalculation(SimpleWaveConditionsCalculation calculation, XmlWriter writer) { - WriteCalculation(calculation, writer); + WriteCalculation(calculation.Name, calculation.Input, writer); } } public class SimpleWaveConditionsCalculation : Observable, ICalculation { + public WaveConditionsInput Input { get; } = new WaveConditionsInput(); public string Name { get; set; } public bool HasOutput { get; } public Comment Comments { get; } public void ClearOutput() { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } - - public WaveConditionsInput Input { get; } = new WaveConditionsInput(); } } \ No newline at end of file Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationContextExportInfoTest.cs =================================================================== diff -u -r4b68fcd10da185da7eef315c45d80a071c6e1bf5 -r69eb17523e5ae490637e29718a4a563cbcaacc3c --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationContextExportInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextExportInfoTest.cs) (revision 4b68fcd10da185da7eef315c45d80a071c6e1bf5) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/ExportInfos/StabilityStoneCoverWaveConditionsCalculationContextExportInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextExportInfoTest.cs) (revision 69eb17523e5ae490637e29718a4a563cbcaacc3c) @@ -74,7 +74,7 @@ var failureMechanism = new StabilityStoneCoverFailureMechanism(); var context = new StabilityStoneCoverWaveConditionsCalculationContext(new StabilityStoneCoverWaveConditionsCalculation(), - failureMechanism, assessmentSection); + failureMechanism, assessmentSection); // Call IFileExporter fileExporter = waveConditionsExportInfo.CreateFileExporter(context, "test"); @@ -105,7 +105,7 @@ var failureMechanism = new StabilityStoneCoverFailureMechanism(); var context = new StabilityStoneCoverWaveConditionsCalculationContext(new StabilityStoneCoverWaveConditionsCalculation(), - failureMechanism, assessmentSection); + failureMechanism, assessmentSection); // Call bool isEnabled = waveConditionsExportInfo.IsEnabled(context); @@ -167,7 +167,7 @@ var failureMechanism = new StabilityStoneCoverFailureMechanism(); var context = new StabilityStoneCoverWaveConditionsCalculationContext(new StabilityStoneCoverWaveConditionsCalculation(), - failureMechanism, assessmentSection); + failureMechanism, assessmentSection); // Call IFileExporter fileExporter = configurationExportInfo.CreateFileExporter(context, "test");