Index: Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs =================================================================== diff -u -r3c1b0b97a6f8a5f3df4b9dad0164e69a886d1330 -rbe661775ee43fd33d21a2aff0068066a1903954b --- Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 3c1b0b97a6f8a5f3df4b9dad0164e69a886d1330) +++ Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision be661775ee43fd33d21a2aff0068066a1903954b) @@ -54,7 +54,7 @@ InitializeComboBoxDataSource(); InitializeEventHandlers(); - UpdateConnectToButton(); + UpdateButtons(); } public string DisplayName @@ -114,9 +114,10 @@ } } - private void UpdateConnectToButton() + private void UpdateButtons() { connectToButton.Enabled = urlLocationComboBox.SelectedItem != null; + editLocationButton.Enabled = urlLocationComboBox.SelectedItem != null; } #region DataGridView @@ -196,7 +197,7 @@ ClearDataGridViewDataSource(); - UpdateConnectToButton(); + UpdateButtons(); } private WmtsConnectionInfo GetSelectedWmtsConnectionInfo() @@ -227,7 +228,11 @@ private void OnConnectToButtonClick(object sender, EventArgs e) { var selectedWmtsConnectionInfo = urlLocationComboBox.SelectedItem as WmtsConnectionInfo; + ConnectToUrl(selectedWmtsConnectionInfo); + } + private void ConnectToUrl(WmtsConnectionInfo selectedWmtsConnectionInfo) + { try { IEnumerable wmtsCapabilities = WmtsCapabilityFactory.GetWmtsCapabilities(selectedWmtsConnectionInfo?.Url).ToArray(); @@ -258,6 +263,7 @@ { wmtsConnectionInfos.Add(createdWmtsConnectionInfos); UpdateComboBoxDataSource(createdWmtsConnectionInfos); + ConnectToUrl(createdWmtsConnectionInfos); } } } @@ -284,6 +290,7 @@ wmtsConnectionInfos.Remove(selectedWmtsConnectionInfo); wmtsConnectionInfos.Add(createdWmtsConnectionInfos); UpdateComboBoxDataSource(createdWmtsConnectionInfos); + ConnectToUrl(createdWmtsConnectionInfos); } } } Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs =================================================================== diff -u -r3c1b0b97a6f8a5f3df4b9dad0164e69a886d1330 -rbe661775ee43fd33d21a2aff0068066a1903954b --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 3c1b0b97a6f8a5f3df4b9dad0164e69a886d1330) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision be661775ee43fd33d21a2aff0068066a1903954b) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; +using BruTile; using Core.Common.Controls.DataGrid; using Core.Common.TestUtil; using Core.Components.DotSpatial.Forms.Views; @@ -290,6 +291,11 @@ const string name = @"someName"; const string url = @"someUrl"; + var mockRepository = new MockRepository(); + var tileFactory = mockRepository.StrictMock(); + tileFactory.Expect(tf => tf.GetWmtsTileSources(url)).Return(Enumerable.Empty()); + mockRepository.ReplayAll(); + DialogBoxHandler = (formName, wnd) => { using (var formTester = new FormTester(formName)) @@ -306,6 +312,7 @@ } }; + using (new UseCustomTileSourceFactoryConfig(tileFactory)) using (var form = new Form()) using (var control = new WmtsLocationControl()) { @@ -328,6 +335,8 @@ var connectToButton = (Button) new ButtonTester("connectToButton", form).TheObject; Assert.IsTrue(connectToButton.Enabled); } + + mockRepository.VerifyAll(); } [Test] @@ -390,6 +399,7 @@ }; var editLocationButton = new ButtonTester("editLocationButton", form); + ((Button) editLocationButton.TheObject).Enabled = true; // When editLocationButton.Click(); @@ -410,6 +420,11 @@ const string newName = @"newName"; const string newUrl = @"newUrl"; + var mockRepository = new MockRepository(); + var tileFactory = mockRepository.StrictMock(); + tileFactory.Expect(tf => tf.GetWmtsTileSources(newUrl)).Return(Enumerable.Empty()); + mockRepository.ReplayAll(); + DialogBoxHandler = (formName, wnd) => { using (var formTester = new FormTester(formName)) @@ -426,6 +441,7 @@ } }; + using (new UseCustomTileSourceFactoryConfig(tileFactory)) using (var form = new Form()) using (var control = new WmtsLocationControl()) { @@ -439,6 +455,7 @@ }; var editLocationButton = new ButtonTester("editLocationButton", form); + ((Button) editLocationButton.TheObject).Enabled = true; // When editLocationButton.Click(); @@ -450,6 +467,8 @@ Assert.AreEqual(newName, item.Name); Assert.AreEqual(newUrl, item.Url); } + + mockRepository.VerifyAll(); } [Test] @@ -486,6 +505,7 @@ }; var editLocationButton = new ButtonTester("editLocationButton", form); + ((Button) editLocationButton.TheObject).Enabled = true; // When editLocationButton.Click();