Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Dialogs/HydraulicBoundaryDatabaseImporterSettingsDialog.cs =================================================================== diff -u -rb6e94550df721ce41b9f524f01bc04cbbfe3fffb -r3a1d0cc96fd4f42500d0a58ac8ba98a7f92720e1 --- Riskeer/Integration/src/Riskeer.Integration.Forms/Dialogs/HydraulicBoundaryDatabaseImporterSettingsDialog.cs (.../HydraulicBoundaryDatabaseImporterSettingsDialog.cs) (revision b6e94550df721ce41b9f524f01bc04cbbfe3fffb) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/Dialogs/HydraulicBoundaryDatabaseImporterSettingsDialog.cs (.../HydraulicBoundaryDatabaseImporterSettingsDialog.cs) (revision 3a1d0cc96fd4f42500d0a58ac8ba98a7f92720e1) @@ -26,6 +26,7 @@ using Core.Common.Gui.Helpers; using Riskeer.Common.Data.Hydraulics; using Riskeer.Integration.Forms.Properties; +using Riskeer.Integration.IO.Importers; using CoreCommonControlsResources = Core.Common.Controls.Properties.Resources; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; @@ -44,19 +45,32 @@ /// /// The dialog parent for which this dialog should be shown on top. /// Object responsible for inquiring the required data. - /// Thrown when any input parameter is null. + /// The settings to use for initialization of the dialog. + /// Thrown when or + /// is null. public HydraulicBoundaryDatabaseImporterSettingsDialog(IWin32Window dialogParent, - IInquiryHelper inquiryHelper) : base(dialogParent, RiskeerCommonFormsResources.DatabaseIcon, 600, 250) + IInquiryHelper inquiryHelper, + HydraulicBoundaryDatabaseImporterSettings settings = null) + : base(dialogParent, RiskeerCommonFormsResources.DatabaseIcon, 600, 250) { this.inquiryHelper = inquiryHelper ?? throw new ArgumentNullException(nameof(inquiryHelper)); InitializeComponent(); FurtherInitializeComponent(); - textBoxHlcd.Text = CoreCommonControlsResources.DisplayName_None; - textBoxHrd.Text = CoreCommonControlsResources.DisplayName_None; - textBoxLocations.Text = CoreCommonControlsResources.DisplayName_None; + if (settings == null) + { + textBoxHlcd.Text = CoreCommonControlsResources.DisplayName_None; + textBoxHrd.Text = CoreCommonControlsResources.DisplayName_None; + textBoxLocations.Text = CoreCommonControlsResources.DisplayName_None; + } + else + { + textBoxHlcd.Text = settings.HlcdFilePath; + textBoxHrd.Text = settings.HrdDirectoryPath; + textBoxLocations.Text = settings.LocationsFilePath; + } UpdateButtonConnect(); } Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Riskeer.Integration.Forms.csproj =================================================================== diff -u -r84812525b441be81b127ac12d6026b339e7ed496 -r3a1d0cc96fd4f42500d0a58ac8ba98a7f92720e1 --- Riskeer/Integration/src/Riskeer.Integration.Forms/Riskeer.Integration.Forms.csproj (.../Riskeer.Integration.Forms.csproj) (revision 84812525b441be81b127ac12d6026b339e7ed496) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/Riskeer.Integration.Forms.csproj (.../Riskeer.Integration.Forms.csproj) (revision 3a1d0cc96fd4f42500d0a58ac8ba98a7f92720e1) @@ -86,6 +86,7 @@ False + False Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Dialogs/HydraulicBoundaryDatabaseImporterSettingsDialogTest.cs =================================================================== diff -u -r951d730bcd552fc4c3807cc107a5d3c3b6adfe26 -r3a1d0cc96fd4f42500d0a58ac8ba98a7f92720e1 --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Dialogs/HydraulicBoundaryDatabaseImporterSettingsDialogTest.cs (.../HydraulicBoundaryDatabaseImporterSettingsDialogTest.cs) (revision 951d730bcd552fc4c3807cc107a5d3c3b6adfe26) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Dialogs/HydraulicBoundaryDatabaseImporterSettingsDialogTest.cs (.../HydraulicBoundaryDatabaseImporterSettingsDialogTest.cs) (revision 3a1d0cc96fd4f42500d0a58ac8ba98a7f92720e1) @@ -31,6 +31,7 @@ using Rhino.Mocks; using Riskeer.Common.Forms.Properties; using Riskeer.Integration.Forms.Dialogs; +using Riskeer.Integration.IO.Importers; namespace Riskeer.Integration.Forms.Test.Dialogs { @@ -86,9 +87,65 @@ } } + [Test] + [Apartment(ApartmentState.STA)] + public void ShowDialog_WithoutSettings_ExpectedValues() + { + // Setup + var mockRepository = new MockRepository(); + var inquiryHelper = mockRepository.Stub(); + mockRepository.ReplayAll(); + + using (var dialogParent = new Form()) + using (var dialog = new HydraulicBoundaryDatabaseImporterSettingsDialog(dialogParent, inquiryHelper)) + { + // Call + dialog.Show(); + + // Assert + var textBoxHlcd = (TextBox) new ControlTester("textBoxHlcd", dialog).TheObject; + Assert.AreEqual("", textBoxHlcd.Text); + + var textBoxHrd = (TextBox) new ControlTester("textBoxHrd", dialog).TheObject; + Assert.AreEqual("", textBoxHrd.Text); + + var textBoxLocations = (TextBox) new ControlTester("textBoxLocations", dialog).TheObject; + Assert.AreEqual("", textBoxLocations.Text); + } + } + + [Test] + [Apartment(ApartmentState.STA)] + public void ShowDialog_WithSettings_ExpectedValues() + { + // Setup + var mockRepository = new MockRepository(); + var inquiryHelper = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var settings = new HydraulicBoundaryDatabaseImporterSettings("path hlcd file", "path hrd directory", "path locations file"); + + using (var dialogParent = new Form()) + using (var dialog = new HydraulicBoundaryDatabaseImporterSettingsDialog(dialogParent, inquiryHelper, settings)) + { + // Call + dialog.Show(); + + // Assert + var textBoxHlcd = (TextBox) new ControlTester("textBoxHlcd", dialog).TheObject; + Assert.AreEqual(settings.HlcdFilePath, textBoxHlcd.Text); + + var textBoxHrd = (TextBox) new ControlTester("textBoxHrd", dialog).TheObject; + Assert.AreEqual(settings.HrdDirectoryPath, textBoxHrd.Text); + + var textBoxLocations = (TextBox) new ControlTester("textBoxLocations", dialog).TheObject; + Assert.AreEqual(settings.LocationsFilePath, textBoxLocations.Text); + } + } + private static Icon BitmapToIcon(Bitmap icon) { return Icon.FromHandle(icon.GetHicon()); } } -} +} \ No newline at end of file