Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs =================================================================== diff -u -r0e50500bb017c821970b286992f14b03dca0e69d -r7dcf169799c42e16f0badadb62624806c4f7fb00 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision 0e50500bb017c821970b286992f14b03dca0e69d) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision 7dcf169799c42e16f0badadb62624806c4f7fb00) @@ -56,8 +56,6 @@ new WmtsLocationControl(mapData as WmtsMapData, new BruTileWmtsCapabilityFactory()) }; - SelectedMapData = mapData; - InitializeComponent(); InitializeButtons(); InitializeComboBox(); @@ -84,11 +82,11 @@ { if (mapData is WellKnownTileSourceMapData) { - return mapDatas.OfType().First(); + return mapDatas.OfType().Single(); } if (mapData is WmtsMapData) { - return mapDatas.OfType().First(); + return mapDatas.OfType().Single(); } return mapDatas.First(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/BackgroundMapDataSelectionDialogTest.cs =================================================================== diff -u -r0e50500bb017c821970b286992f14b03dca0e69d -r7dcf169799c42e16f0badadb62624806c4f7fb00 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/BackgroundMapDataSelectionDialogTest.cs (.../BackgroundMapDataSelectionDialogTest.cs) (revision 0e50500bb017c821970b286992f14b03dca0e69d) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/BackgroundMapDataSelectionDialogTest.cs (.../BackgroundMapDataSelectionDialogTest.cs) (revision 7dcf169799c42e16f0badadb62624806c4f7fb00) @@ -62,21 +62,6 @@ } [Test] - public void Constructor_WithoutParent_ThrowsArgumentNullException() - { - // Setup - mockRepository.ReplayAll(); - var imageBasedMapData = new TestImageBasedMapData("someMapData", true); - - // Call - TestDelegate test = () => new BackgroundMapDataSelectionDialog(null, imageBasedMapData); - - // Assert - string parameter = Assert.Throws(test).ParamName; - Assert.AreEqual("dialogParent", parameter); - } - - [Test] public void Constructor_MapDataNull_DefaultProperties() { // Setup @@ -89,26 +74,13 @@ // Assert Assert.IsInstanceOf(dialog); Assert.AreEqual("Selecteer achtergrondkaart", dialog.Text); - Assert.IsNull(dialog.SelectedMapData); Icon icon = BitmapToIcon(RingtoetsCommonFormsResources.SelectionDialogIcon); Bitmap expectedImage = icon.ToBitmap(); Bitmap actualImage = dialog.Icon.ToBitmap(); TestHelper.AssertImagesAreEqual(expectedImage, actualImage); - var mapLayers = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; - Assert.AreEqual(ComboBoxStyle.DropDownList, mapLayers.DropDownStyle); - Assert.AreEqual("DisplayName", mapLayers.DisplayMember); - Assert.IsTrue(mapLayers.Sorted); - - var backgroundMapDataSelectionControls = (IBackgroundMapDataSelectionControl[]) mapLayers.DataSource; - Assert.AreEqual(2, backgroundMapDataSelectionControls.Length); - Assert.IsInstanceOf(backgroundMapDataSelectionControls[0]); - Assert.IsInstanceOf(backgroundMapDataSelectionControls[1]); - - var groupBoxProperties = (GroupBox) new ControlTester("propertiesGroupBox", dialog).TheObject; - Assert.AreEqual(1, groupBoxProperties.Controls.Count); - Assert.AreSame(backgroundMapDataSelectionControls[0], groupBoxProperties.Controls[0]); + AssertMapDataControls(dialog); } } @@ -142,13 +114,7 @@ using (var dialog = new BackgroundMapDataSelectionDialog(dialogParent, mapData)) { // Assert - Assert.AreSame(mapData, dialog.SelectedMapData); - var mapLayers = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; - Assert.IsInstanceOf(mapLayers.SelectedItem); - - var groupBoxProperties = (GroupBox) new ControlTester("propertiesGroupBox", dialog).TheObject; - Assert.AreEqual(1, groupBoxProperties.Controls.Count); - Assert.AreSame(mapLayers.SelectedItem, groupBoxProperties.Controls[0]); + AssertMapDataControls(dialog); } } } @@ -169,17 +135,7 @@ using (var dialog = new BackgroundMapDataSelectionDialog(dialogParent, mapData)) { // Assert - Assert.AreSame(mapData, dialog.SelectedMapData); - var mapLayers = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; - Assert.AreEqual(ComboBoxStyle.DropDownList, mapLayers.DropDownStyle); - Assert.IsInstanceOf(mapLayers.DataSource); - Assert.AreEqual("DisplayName", mapLayers.DisplayMember); - Assert.IsTrue(mapLayers.Sorted); - Assert.IsInstanceOf(mapLayers.SelectedItem); - - var groupBoxProperties = (GroupBox) new ControlTester("propertiesGroupBox", dialog).TheObject; - Assert.AreEqual(1, groupBoxProperties.Controls.Count); - Assert.AreSame(mapLayers.SelectedItem, groupBoxProperties.Controls[0]); + AssertMapDataControls(dialog); } } } @@ -190,16 +146,12 @@ { // Setup mockRepository.ReplayAll(); - DialogBoxHandler = (name, wnd) => - { - using (new FormTester(name)) {} - }; using (var dialogParent = new Form()) using (var dialog = new BackgroundMapDataSelectionDialog(dialogParent, null)) { // Call - dialog.ShowDialog(); + dialog.Show(); // Assert var mapLayerLabel = new LabelTester("mapLayerLabel", dialog); @@ -315,14 +267,17 @@ wmtsLocationControl.SelectedMapDataChanged += (sender, args) => { wmtsLocationControlSelectedMapDataChanged++; }; comboBox.SelectedItem = GetComboBoxItem(comboBox); + var wellKnownDataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject; + wellKnownDataGridViewControl.ClearCurrentCell(); + var button = (Button) new ButtonTester("selectButton", dialog).TheObject; + Assert.IsFalse(button.Enabled); + // When wmtsDataGridViewControl.SetCurrentCell(wmtsDataGridViewControl.GetCell(0, 0)); - var button = new ButtonTester("selectButton", dialog); - button.Click(); // Then - Assert.IsInstanceOf(dialog.SelectedMapData); + Assert.IsFalse(button.Enabled); Assert.AreEqual(1, wmtsLocationControlSelectedMapDataChanged); } } @@ -393,6 +348,30 @@ Assert.DoesNotThrow(call); } + private static void AssertMapDataControls(BackgroundMapDataSelectionDialog dialog) + where T : UserControl, IBackgroundMapDataSelectionControl + { + var mapLayers = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; + Assert.AreEqual("DisplayName", mapLayers.DisplayMember); + Assert.AreEqual("UserControl", mapLayers.ValueMember); + Assert.AreEqual(ComboBoxStyle.DropDownList, mapLayers.DropDownStyle); + Assert.IsTrue(mapLayers.Sorted); + Assert.IsInstanceOf(mapLayers.SelectedItem); + + var backgroundMapDataSelectionControls = (IBackgroundMapDataSelectionControl[]) mapLayers.DataSource; + Assert.AreEqual(2, backgroundMapDataSelectionControls.Length); + Assert.IsInstanceOf(backgroundMapDataSelectionControls[0]); + Assert.IsInstanceOf(backgroundMapDataSelectionControls[1]); + + Assert.IsInstanceOf(mapLayers.DataSource); + Assert.AreEqual("DisplayName", mapLayers.DisplayMember); + + var groupBoxProperties = (GroupBox) new ControlTester("propertiesGroupBox", dialog).TheObject; + Assert.AreEqual(DockStyle.Fill, groupBoxProperties.Dock); + Assert.AreEqual(1, groupBoxProperties.Controls.Count); + Assert.AreSame(mapLayers.SelectedItem, groupBoxProperties.Controls[0]); + } + private static T GetComboBoxItem(ComboBox comboBox) { return ((IBackgroundMapDataSelectionControl[]) comboBox.DataSource).OfType().First(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -r7348fb685e44d6eb4abf2854c8298c0a2189d67e -r7dcf169799c42e16f0badadb62624806c4f7fb00 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 7348fb685e44d6eb4abf2854c8298c0a2189d67e) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 7dcf169799c42e16f0badadb62624806c4f7fb00) @@ -41,6 +41,10 @@ MinimumRecommendedRules.ruleset + + ..\..\..\..\packages\BruTile.0.19.0\lib\net40\BruTile.dll + True + ..\..\..\..\packages\Fluent.Ribbon.3.4.0\lib\net40\Fluent.dll True @@ -160,6 +164,10 @@ {d749ee4c-ce50-4c17-bf01-9a953028c126} Core.Common.TestUtil + + {E02482C7-F12B-42F0-BB2B-C7EC17503A72} + Core.Components.BruTile + {4a06df0d-5d75-4bad-a95a-a3db9b7c4ad5} Core.Components.Gis.Forms @@ -168,6 +176,10 @@ {318ba582-88c9-4816-a54a-a7e431461de3} Core.Components.Gis + + {1081336C-D919-4249-AB33-9AF15F4D19EC} + Core.Components.BruTile.TestUtil + {c6309704-d67b-434c-bc98-9f8910bc1d10} Ringtoets.ClosingStructures.Data @@ -260,14 +272,6 @@ {87c2c553-c0bc-40bf-b1ea-b83bff357f27} Ringtoets.Revetment.Data - - {E3347B16-BB18-41C1-8D34-FBCBF20DB695} - Ringtoets.Revetment.IO - - - {3706200E-48C6-4B86-B48C-4E45C69ABE95} - Ringtoets.Revetment.Data.TestUtil - {3d4b9740-8348-4434-8d77-b611fc6ee57f} Ringtoets.StabilityPointStructures.Data @@ -292,10 +296,6 @@ {1AC97B51-88C2-437D-89E6-65C69AB3CCAD} Ringtoets.WaveImpactAsphaltCover.Forms - - {83A782F1-BA78-4D5C-B213-39066605AFD8} - Ringtoets.WaveImpactAsphaltCover.Plugin - {11f1f874-45af-43e4-8ae5-15a5c9593e28} Ringtoets.Integration.Data @@ -308,10 +308,6 @@ {c8383b76-b3f1-4e6e-b56c-527b469fa20a} Ringtoets.Integration.Plugin - - {28811c4a-6c18-42c1-88b2-a03a3784e2d0} - Ringtoets.Integration.Service - {174ba68d-6176-4ac5-8dfd-98cdd2c4d971} Ringtoets.Integration.TestUtils Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs =================================================================== diff -u -rf9db544ad22552799aaaedc2a154abd8765f7099 -r7dcf169799c42e16f0badadb62624806c4f7fb00 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs (.../BackgroundDataTreeNodeInfoTest.cs) (revision f9db544ad22552799aaaedc2a154abd8765f7099) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs (.../BackgroundDataTreeNodeInfoTest.cs) (revision 7dcf169799c42e16f0badadb62624806c4f7fb00) @@ -30,7 +30,10 @@ using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms.MainWindow; using Core.Common.Gui.TestUtil.ContextMenu; +using Core.Common.Gui.TestUtil.Settings; using Core.Common.TestUtil; +using Core.Components.BruTile.Configurations; +using Core.Components.BruTile.TestUtil; using Core.Components.Gis.Data; using Core.Components.Gis.Forms.Views; using NUnit.Extensions.Forms; @@ -240,10 +243,18 @@ } [Test] - public void GivenNoMapDataSet_WhenSelectingValidMapDataFromContextMenu_ThenMapDataSetAndNotifiesObserver() + public void GivenNoMapDataSet_WhenSelectingValidWMTSMapDataFromContextMenu_ThenMapDataSetAndNotifiesObserver() { // Given var mockRepository = new MockRepository(); + var tileFactory = mockRepository.StrictMock(); + WmtsMapData newMapData = new WmtsMapData("Actueel Hoogtebestand Nederland (AHN1)", + "https://geodata.nationaalgeoregister.nl/tiles/service/wmts/ahn1?request=GetCapabilities", + "()", "image/png"); + tileFactory.Expect(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(new[] + { + new TestWmtsTileSource(newMapData) + }); var assessmentSectionObserver = mockRepository.StrictMock(); assessmentSectionObserver.Expect(o => o.UpdateObserver()); @@ -253,6 +264,11 @@ WmtsMapData mapData = WmtsMapData.CreateUnconnectedMapData(); BackgroundData backgroundData = BackgroundDataTestDataGenerator.GetWmtsBackgroundMapData(mapData); + using (new UseCustomSettingsHelper(new TestSettingsHelper + { + ApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "twoValidWmtsConnectionInfos") + })) + using (new UseCustomTileSourceFactoryConfig(tileFactory)) using (var treeViewControl = new TreeViewControl()) using (var plugin = new RingtoetsPlugin()) { @@ -273,9 +289,10 @@ DialogBoxHandler = (name, wnd) => { - var tester = (BackgroundMapDataSelectionDialog) new FormTester(name).TheObject; - tester.DialogResult = DialogResult.OK; - tester.Close(); + var dialog = (BackgroundMapDataSelectionDialog) new FormTester(name).TheObject; + var button = new ButtonTester("selectButton", dialog); + button.Click(); + dialog.Close(); }; TreeNodeInfo info = GetInfo(plugin); @@ -287,7 +304,7 @@ contextMenuStrip.Items[selectContextMenuIndex].PerformClick(); // Then - AssertBackgroundMapDataProperties(mapData, assessmentSection.BackgroundData); + AssertBackgroundMapDataProperties(newMapData, assessmentSection.BackgroundData, true); } } mockRepository.VerifyAll(); @@ -323,7 +340,7 @@ var assessmentSection = new ObservableTestAssessmentSectionStub(); assessmentSection.Attach(assessmentSectionObserver); assessmentSection.BackgroundData.Attach(backgroundMapDataObserver); - + BackgroundData oldBackgroundData = assessmentSection.BackgroundData; DialogBoxHandler = (name, wnd) => @@ -393,9 +410,10 @@ DialogBoxHandler = (name, wnd) => { - var tester = (BackgroundMapDataSelectionDialog) new FormTester(name).TheObject; - tester.DialogResult = DialogResult.OK; - tester.Close(); + var dialog = (BackgroundMapDataSelectionDialog) new FormTester(name).TheObject; + var button = new ButtonTester("selectButton", dialog); + button.Click(); + dialog.Close(); }; TreeNodeInfo info = GetInfo(plugin); @@ -407,7 +425,7 @@ contextMenuStrip.Items[selectContextMenuIndex].PerformClick(); // Then - AssertBackgroundMapDataProperties(newMapData, assessmentSection.BackgroundData); + AssertBackgroundMapDataProperties(newMapData, assessmentSection.BackgroundData, true); } } mockRepository.VerifyAll(); @@ -452,11 +470,11 @@ DialogBoxHandler = (name, wnd) => { - var dialog = (BackgroundMapDataSelectionDialog)new FormTester(name).TheObject; + var dialog = (BackgroundMapDataSelectionDialog) new FormTester(name).TheObject; - var comboBox = (ComboBox)new ComboBoxTester("mapLayerComboBox", dialog).TheObject; - comboBox.SelectedItem = ((IBackgroundMapDataSelectionControl[])comboBox.DataSource).OfType().First(); - var wmtsDataGridViewControl = (DataGridViewControl)new ControlTester("dataGridViewControl", dialog).TheObject; + var comboBox = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; + comboBox.SelectedItem = ((IBackgroundMapDataSelectionControl[]) comboBox.DataSource).OfType().First(); + var wmtsDataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject; wmtsDataGridViewControl.SetCurrentCell(wmtsDataGridViewControl.GetCell(1, 0)); var button = new ButtonTester("selectButton", dialog); @@ -473,6 +491,7 @@ contextMenuStrip.Items[selectContextMenuIndex].PerformClick(); // Then + AssertBackgroundMapDataProperties(mapData, assessmentSection.BackgroundData, false); } } mockRepository.VerifyAll(); @@ -536,10 +555,10 @@ mockRepository.VerifyAll(); } - private static void AssertBackgroundMapDataProperties(WmtsMapData mapData, BackgroundData backgroundData) + private static void AssertBackgroundMapDataProperties(WmtsMapData mapData, BackgroundData backgroundData, bool shouldBeVisible) { Assert.AreEqual(mapData.Name, backgroundData.Name); - Assert.IsTrue(backgroundData.IsVisible); + Assert.AreEqual(shouldBeVisible, backgroundData.IsVisible); Assert.AreEqual(mapData.IsConfigured, backgroundData.IsConfigured); Assert.AreEqual(mapData.Transparency, backgroundData.Transparency); Assert.AreEqual(mapData.SourceCapabilitiesUrl, backgroundData.Parameters[BackgroundDataIdentifiers.SourceCapabilitiesUrl]); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/packages.config =================================================================== diff -u -r6a5d7b40b7ba4dcb73e393075338352d194e97c2 -r7dcf169799c42e16f0badadb62624806c4f7fb00 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/packages.config (.../packages.config) (revision 6a5d7b40b7ba4dcb73e393075338352d194e97c2) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/packages.config (.../packages.config) (revision 7dcf169799c42e16f0badadb62624806c4f7fb00) @@ -22,6 +22,7 @@ All rights reserved. --> +