Index: Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs
===================================================================
diff -u -r888f6cdc81e8fb6d6a5b9baadf6395f209008836 -r9159e629e90a794aa18b28d61c6b7904407acbcc
--- Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision 888f6cdc81e8fb6d6a5b9baadf6395f209008836)
+++ Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision 9159e629e90a794aa18b28d61c6b7904407acbcc)
@@ -117,6 +117,36 @@
}
///
+ /// Clears the current cell.
+ ///
+ public void ClearCurrentCell()
+ {
+ dataGridView.CurrentCell = null;
+ }
+
+ ///
+ /// Sets the currently active cell.
+ ///
+ /// Sets the cell to be set active.
+ /// Thrown when:
+ /// - is not in the DataGridView;
+ /// - cannot be
+ /// set because changes to the current cell cannot be committed or canceled.
+ ///
+ ///
+ public void SetCurrentCell(DataGridViewCell cell)
+ {
+ try
+ {
+ dataGridView.CurrentCell = cell;
+ }
+ catch (Exception e) when (e is ArgumentException || e is InvalidOperationException)
+ {
+ throw new ArgumentException(@"Unable to set the cell active.", nameof(cell));
+ }
+ }
+
+ ///
/// Adds a new to the with the given data.
///
/// The of the column.
@@ -424,14 +454,6 @@
dataGridView.CellValueChanged -= handler;
}
- ///
- /// Clears the current cell.
- ///
- public void ClearCurrentCell()
- {
- dataGridView.CurrentCell = null;
- }
-
private void SubscribeEvents()
{
dataGridView.ColumnAdded += DataGridViewOnColumnAdded;
Index: Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs
===================================================================
diff -u -r4faae1433690b9b06b40c18ff322140aa16df739 -r9159e629e90a794aa18b28d61c6b7904407acbcc
--- Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision 4faae1433690b9b06b40c18ff322140aa16df739)
+++ Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision 9159e629e90a794aa18b28d61c6b7904407acbcc)
@@ -516,7 +516,7 @@
form.Controls.Add(control);
form.Show();
- var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
// Precondition
Assert.AreEqual(0, dataGridView.ColumnCount);
@@ -527,7 +527,7 @@
// Assert
Assert.AreEqual(1, dataGridView.ColumnCount);
- DataGridViewColorColumn columnData = (DataGridViewColorColumn)dataGridView.Columns[0];
+ DataGridViewColorColumn columnData = (DataGridViewColorColumn) dataGridView.Columns[0];
Assert.AreEqual(propertyName, columnData.DataPropertyName);
Assert.AreEqual($"column_{propertyName}", columnData.Name);
Assert.AreEqual(headerText, columnData.HeaderText);
@@ -549,7 +549,7 @@
form.Controls.Add(control);
form.Show();
- var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject;
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
// Precondition
Assert.AreEqual(0, dataGridView.ColumnCount);
@@ -560,7 +560,7 @@
// Assert
Assert.AreEqual(1, dataGridView.ColumnCount);
- DataGridViewColorColumn columnData = (DataGridViewColorColumn)dataGridView.Columns[0];
+ DataGridViewColorColumn columnData = (DataGridViewColorColumn) dataGridView.Columns[0];
Assert.AreEqual(propertyName, columnData.DataPropertyName);
Assert.AreEqual($"column_{propertyName}", columnData.Name);
Assert.AreEqual(headerText, columnData.HeaderText);
@@ -1128,6 +1128,95 @@
}
}
+ [Test]
+ public void SetCurrentCell_ValidCell_SetsCurrentCell()
+ {
+ // Setup
+ using (var form = new Form())
+ using (var control = new DataGridViewControl())
+ {
+ form.Controls.Add(control);
+ form.Show();
+
+ control.AddTextBoxColumn("Test property", "Test header");
+
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ dataGridView.DataSource = new[]
+ {
+ ""
+ };
+
+ dataGridView.CurrentCell = null;
+ DataGridViewCell firstcell = dataGridView.Rows[0].Cells[0];
+
+ // Call
+ control.SetCurrentCell(firstcell);
+
+ // Assert
+ Assert.AreSame(firstcell, dataGridView.CurrentCell);
+ }
+ }
+
+ [Test]
+ public void SetCurrentCell_CellIsHeaderCell_ThrowsArgumentException()
+ {
+ // Setup
+ using (var form = new Form())
+ using (var control = new DataGridViewControl())
+ {
+ form.Controls.Add(control);
+ form.Show();
+
+ control.AddTextBoxColumn("Test property", "Test header");
+
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ dataGridView.DataSource = new[]
+ {
+ ""
+ };
+
+ DataGridViewCell firstcell = dataGridView.Rows[0].HeaderCell;
+
+ // Call
+ TestDelegate test = () => control.SetCurrentCell(firstcell);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("cell", paramName);
+ }
+ }
+
+ [Test]
+ public void SetCurrentCell_ValidCellButRowIsHidden_ThrowsArgumentException()
+ {
+ // Setup
+ using (var form = new Form())
+ using (var control = new DataGridViewControl())
+ {
+ form.Controls.Add(control);
+ form.Show();
+
+ control.AddTextBoxColumn("Test property", "Test header");
+
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ dataGridView.DataSource = new[]
+ {
+ "",
+ ""
+ };
+
+ DataGridViewRow dataGridViewRow = dataGridView.Rows[1];
+ dataGridViewRow.Visible = false;
+
+ // Call
+ TestDelegate test = () => control.SetCurrentCell(dataGridViewRow.Cells[0]);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("cell", paramName);
+ }
+ }
+
[TestCase(true)]
[TestCase(false)]
public void RestoreCell_WithoutSpecificReadOnlyState_SetsCellStyleToEnabledWithColumnReadOnlyState(bool columnReadOnlyState)
Index: Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs
===================================================================
diff -u -r5ee68bb6e2d903af666a6e927e4f67b916c88848 -r9159e629e90a794aa18b28d61c6b7904407acbcc
--- Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 5ee68bb6e2d903af666a6e927e4f67b916c88848)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 9159e629e90a794aa18b28d61c6b7904407acbcc)
@@ -116,7 +116,7 @@
{
WmtsConnectionInfo suggestedInfo = TryCreateWmtsConnectionInfo(activeWmtsMapData?.Name,
activeWmtsMapData?.SourceCapabilitiesUrl);
- if (suggestedInfo == null)
+ if (activeWmtsMapData == null || suggestedInfo == null)
{
return;
}
@@ -127,8 +127,25 @@
}
UpdateComboBoxDataSource(suggestedInfo);
+
+ DataGridViewRow dataGridViewRow = dataGridViewControl.Rows.OfType()
+ .FirstOrDefault(row => IsMatch(
+ (WmtsCapabilityRow) row.DataBoundItem,
+ activeWmtsMapData));
+ if (dataGridViewRow == null)
+ {
+ return;
+ }
+ DataGridViewCell cell = dataGridViewControl.Rows[dataGridViewRow.Index].Cells[0];
+ dataGridViewControl.SetCurrentCell(cell);
}
+ private static bool IsMatch(WmtsCapabilityRow wmtsCapabilityRow, WmtsMapData wmtsMapData)
+ {
+ return string.Equals(wmtsCapabilityRow.Id, wmtsMapData.SelectedCapabilityIdentifier)
+ && string.Equals(wmtsCapabilityRow.Format, wmtsMapData.PreferredFormat);
+ }
+
private void InitializeWmtsConnectionInfos()
{
string applicationVersion = SettingsHelper.Instance.ApplicationVersion;
Index: Core/Components/src/Core.Components.DotSpatial.Forms/WmtsConnectionInfo.cs
===================================================================
diff -u -r3f2252d8d17eed894f5f37fd7e8abfff6cdcbf74 -r9159e629e90a794aa18b28d61c6b7904407acbcc
--- Core/Components/src/Core.Components.DotSpatial.Forms/WmtsConnectionInfo.cs (.../WmtsConnectionInfo.cs) (revision 3f2252d8d17eed894f5f37fd7e8abfff6cdcbf74)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/WmtsConnectionInfo.cs (.../WmtsConnectionInfo.cs) (revision 9159e629e90a794aa18b28d61c6b7904407acbcc)
@@ -78,7 +78,7 @@
{
return true;
}
- return Name.Equals(other.Name) && string.Equals(Url, other.Url);
+ return string.Equals(Name, other.Name) && string.Equals(Url, other.Url);
}
public override bool Equals(object obj)
Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs
===================================================================
diff -u -r5ee68bb6e2d903af666a6e927e4f67b916c88848 -r9159e629e90a794aa18b28d61c6b7904407acbcc
--- Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 5ee68bb6e2d903af666a6e927e4f67b916c88848)
+++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 9159e629e90a794aa18b28d61c6b7904407acbcc)
@@ -51,43 +51,73 @@
private static readonly TestDataPath testPath = TestDataPath.Core.Components.DotSpatial.Forms;
+ private MockRepository mockRepository;
+ private ITileSourceFactory tileFactory;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mockRepository = new MockRepository();
+ tileFactory = mockRepository.StrictMock();
+ }
+
+ [TearDown]
+ public override void TearDown()
+ {
+ mockRepository.VerifyAll();
+ base.TearDown();
+ }
+
[Test]
public void Constructor_ActiveWmtsMapDataNull_DefaultValues()
{
- // Call
- using (var control = new WmtsLocationControl(null))
+ // Setup
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
{
- // Assert
- Assert.IsInstanceOf(control);
- Assert.IsInstanceOf(control);
- Assert.AreEqual("Web Map Tile Service (WMTS)", control.DisplayName);
- Assert.IsNull(control.SelectedMapData);
- Assert.AreSame(control, control.UserControl);
+ // Call
+ using (var control = new WmtsLocationControl(null))
+ {
+ // Assert
+ Assert.IsInstanceOf(control);
+ Assert.IsInstanceOf(control);
+ Assert.AreEqual("Web Map Tile Service (WMTS)", control.DisplayName);
+ Assert.IsNull(control.SelectedMapData);
+ Assert.AreSame(control, control.UserControl);
+ }
}
}
[Test]
- public void Constructor_ValidWmtsMapData_DefaultValues()
+ public void Constructor_ValidWmtsMapData_ExpectedProperties()
{
// Setup
WmtsMapData activeWmtsMapData = WmtsMapData.CreateDefaultPdokMapData();
+ tileFactory.Expect(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(new[]
+ {
+ new TestWmtsTileSource(activeWmtsMapData)
+ });
+ mockRepository.ReplayAll();
- // Call
- using (var control = new WmtsLocationControl(activeWmtsMapData))
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
{
- // Assert
- Assert.IsInstanceOf(control);
- Assert.IsInstanceOf(control);
- Assert.AreEqual("Web Map Tile Service (WMTS)", control.DisplayName);
- Assert.IsNull(control.SelectedMapData);
- Assert.AreSame(control, control.UserControl);
+ // Call
+ using (var control = new WmtsLocationControl(activeWmtsMapData))
+ {
+ // Assert
+ AssertAreEqual(activeWmtsMapData, control.SelectedMapData);
+ }
}
}
[Test]
public void Show_AddedToForm_DefaultProperties()
{
// Setup
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (var control = new WmtsLocationControl(null))
using (var form = new Form())
{
@@ -123,8 +153,15 @@
{
// Setup
WmtsMapData activeWmtsMapData = WmtsMapData.CreateDefaultPdokMapData();
+ tileFactory.Expect(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(new[]
+ {
+ new TestWmtsTileSource(activeWmtsMapData)
+ });
+ mockRepository.ReplayAll();
+
var activeWmtsConnectionInfo = new WmtsConnectionInfo(activeWmtsMapData.Name, activeWmtsMapData.SourceCapabilitiesUrl);
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (var control = new WmtsLocationControl(activeWmtsMapData))
using (var form = new Form())
{
@@ -152,9 +189,12 @@
}
[Test]
- public void Constructor_DataGridViewCorrectlyInitialized()
+ public void Constructor_NullMapData_DataGridViewCorrectlyInitialized()
{
// Call
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (var control = new WmtsLocationControl(null))
using (var form = new Form())
{
@@ -191,26 +231,93 @@
}
[Test]
- public void Dispose_AlreadyDisposed_DoesNotThrowException()
+ public void Constructor_ValidMapDataWithITileSources_ExpectedDataGrid()
{
- // Call
- TestDelegate call = () =>
+ // Setup
+ WmtsMapData activeWmtsMapData = WmtsMapData.CreateDefaultPdokMapData();
+
+ var tileSources = new[]
{
- using (var control = new WmtsLocationControl(null))
+ new TestWmtsTileSource(WmtsMapData.CreateAlternativePdokMapData()),
+ new TestWmtsTileSource(activeWmtsMapData)
+ };
+
+ tileFactory.Expect(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(tileSources);
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
+ {
+ // Call
+ using (var control = new WmtsLocationControl(activeWmtsMapData))
+ using (var form = new Form())
{
- control.Dispose();
+ form.Controls.Add(control);
+
+ // Assert
+ var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject;
+ Assert.AreEqual(2, dataGridViewControl.Rows.Count);
+ DataGridViewRow currentRow = dataGridViewControl.CurrentRow;
+ Assert.IsNotNull(currentRow);
+ Assert.AreEqual(1, currentRow.Cells[0].RowIndex);
}
- };
+ }
+ }
- // Assert
- Assert.DoesNotThrow(call);
+ [Test]
+ public void Constructor_ValidMapDataWithoutITileSources_DataGridEmpty()
+ {
+ // Setup
+ WmtsMapData activeWmtsMapData = WmtsMapData.CreateDefaultPdokMapData();
+
+ tileFactory.Expect(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(Enumerable.Empty());
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
+ {
+ // Call
+ using (var control = new WmtsLocationControl(activeWmtsMapData))
+ using (var form = new Form())
+ {
+ form.Controls.Add(control);
+
+ // Assert
+ var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject;
+ Assert.IsEmpty(dataGridViewControl.Rows);
+ }
+ }
}
[Test]
+ public void Dispose_AlreadyDisposed_DoesNotThrowException()
+ {
+ // Setup
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
+ {
+ // Call
+ TestDelegate call = () =>
+ {
+ using (var control = new WmtsLocationControl(null))
+ {
+ control.Dispose();
+ }
+ };
+
+ // Assert
+ Assert.DoesNotThrow(call);
+ }
+ }
+
+ [Test]
[Apartment(ApartmentState.STA)]
public void WmtsLocationControl_WithData_DataGridViewCorrectlyInitialized()
{
// Setup
+ tileFactory.Stub(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(Enumerable.Empty());
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (new UseCustomSettingsHelper(new TestSettingsHelper
{
ExpectedApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(testPath, "noConfig")
@@ -247,6 +354,9 @@
public void GetSelectedMapData_WithoutSelectedData_ReturnsNull()
{
// Setup
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (var form = new Form())
using (var control = new WmtsLocationControl(null))
{
@@ -265,6 +375,10 @@
public void GetSelectedMapData_WithSelectedComboBoxWithoutSelectedRow_ReturnsNull()
{
// Setup
+ tileFactory.Stub(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(Enumerable.Empty());
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (new UseCustomSettingsHelper(new TestSettingsHelper
{
ExpectedApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(testPath, "noConfig")
@@ -283,6 +397,9 @@
public void GetSelectedMapData_WithoutSelectedComboBoxWithSelectedRow_ReturnsNull()
{
// Setup
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (var form = new Form())
using (var control = new WmtsLocationControl(null))
{
@@ -310,6 +427,10 @@
public void GetSelectedMapData_WithSelectedData_ReturnsSelectedMapData()
{
// Setup
+ tileFactory.Stub(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(Enumerable.Empty());
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (new UseCustomSettingsHelper(new TestSettingsHelper
{
ExpectedApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(testPath, "noConfig")
@@ -339,6 +460,9 @@
public void GivenValidWmtsConnectionInfos_WhenConstructed_ThenExpectedProperties()
{
// Given
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (new UseCustomSettingsHelper(new TestSettingsHelper
{
ExpectedApplicationVersion = "twoValidWmtsConnectionInfos",
@@ -374,6 +498,9 @@
public void GivenInvalidWmtsConnectionInfos_WhenConstructed_ThenLogGenerated()
{
// Given
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (new UseCustomSettingsHelper(new TestSettingsHelper
{
ExpectedApplicationVersion = "WmtsConnectionInfosWithoutWmtsConnectionsElement",
@@ -410,11 +537,14 @@
public void GivenWmtsLocationControlAndAddLocationClicked_WhenDialogCanceled_ThenWmtsLocationsNotUpdated()
{
// Given
+ mockRepository.ReplayAll();
+
DialogBoxHandler = (formName, wnd) =>
{
using (new FormTester(formName)) {}
};
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (new UseCustomSettingsHelper(new TestSettingsHelper
{
ExpectedApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(testPath, "noConfig")
@@ -445,8 +575,6 @@
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();
@@ -495,15 +623,15 @@
var connectToButton = (Button) new ButtonTester("connectToButton", form).TheObject;
Assert.IsTrue(connectToButton.Enabled);
}
-
- mockRepository.VerifyAll();
}
[Test]
[Apartment(ApartmentState.STA)]
public void GivenWmtsLocationControlAndAddLocationClicked_WhenInValidDataInDialog_ThenWmtsLocationsNotUpdated()
{
// Given
+ mockRepository.ReplayAll();
+
DialogBoxHandler = (formName, wnd) =>
{
using (var formTester = new FormTester(formName))
@@ -517,6 +645,7 @@
}
};
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
using (new UseCustomSettingsHelper(new TestSettingsHelper
{
ExpectedApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(testPath, "noConfig")
@@ -550,8 +679,6 @@
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();
@@ -602,17 +729,13 @@
Assert.AreEqual(1, dataSource.Count);
}
}
-
- mockRepository.VerifyAll();
}
[Test]
[Apartment(ApartmentState.STA)]
public void GivenWmtsLocationControlAndEditLocationClicked_WhenDialogCanceled_ThenWmtsLocationsNotUpdated()
{
// Given
- var mockRepository = new MockRepository();
- var tileFactory = mockRepository.StrictMock();
tileFactory.Expect(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(Enumerable.Empty());
mockRepository.ReplayAll();
@@ -651,8 +774,6 @@
Assert.AreEqual("oldName", item.Name);
Assert.AreEqual("oldUrl", item.Url);
}
-
- mockRepository.VerifyAll();
}
[Test]
@@ -663,8 +784,6 @@
const string newName = @"newName";
const string newUrl = @"newUrl";
- var mockRepository = new MockRepository();
- var tileFactory = mockRepository.StrictMock();
tileFactory.Expect(tf => tf.GetWmtsTileSources("oldUrl")).Return(Enumerable.Empty());
tileFactory.Expect(tf => tf.GetWmtsTileSources(newUrl)).Return(Enumerable.Empty());
mockRepository.ReplayAll();
@@ -717,17 +836,13 @@
Assert.AreEqual(newName, item.Name);
Assert.AreEqual(newUrl, item.Url);
}
-
- mockRepository.VerifyAll();
}
[Test]
[Apartment(ApartmentState.STA)]
public void GivenWmtsLocationControlAndEditLocationClicked_WhenInValidDataInDialog_ThenWmtsLocationsNotUpdated()
{
// Given
- var mockRepository = new MockRepository();
- var tileFactory = mockRepository.StrictMock();
tileFactory.Expect(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(Enumerable.Empty());
mockRepository.ReplayAll();
@@ -781,14 +896,14 @@
var connectToButton = (Button) new ButtonTester("connectToButton", form).TheObject;
Assert.IsFalse(connectToButton.Enabled);
}
-
- mockRepository.VerifyAll();
}
[Test]
public void GivenWmtsLocationControlAndConnectClicked_WhenValidDataFromUrl_ThenDataGridUpdated()
{
// Given
+ mockRepository.ReplayAll();
+
WmtsMapData backgroundMapData = WmtsMapData.CreateDefaultPdokMapData();
using (new UseCustomTileSourceFactoryConfig(backgroundMapData))
@@ -822,8 +937,6 @@
// Given
const string exceptionMessage = "fail";
- var mockRepository = new MockRepository();
- var tileFactory = mockRepository.StrictMock();
tileFactory.Expect(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Return(Enumerable.Empty());
tileFactory.Expect(tf => tf.GetWmtsTileSources(null)).IgnoreArguments().Throw(new CannotFindTileSourceException(exceptionMessage));
mockRepository.ReplayAll();
@@ -854,28 +967,46 @@
Assert.AreEqual("Fout", messageBoxTitle);
Assert.AreEqual(exceptionMessage, messageBoxText);
}
- mockRepository.VerifyAll();
}
[Test]
public void Dispose_DisposedAlreadyCalled_DoesNotThrowException()
{
- // Call
- TestDelegate call = () =>
+ // Setup
+ mockRepository.ReplayAll();
+
+ using (new UseCustomTileSourceFactoryConfig(tileFactory))
{
- using (var control = new WmtsLocationControl(null))
+ // Call
+ TestDelegate call = () =>
{
- control.Dispose();
- }
- };
+ using (var control = new WmtsLocationControl(null))
+ {
+ control.Dispose();
+ }
+ };
- // Assert
- Assert.DoesNotThrow(call);
+ // Assert
+ Assert.DoesNotThrow(call);
+ }
}
- private static WmtsLocationControl ShowFullyConfiguredWmtsLocationControl()
+ private static void AssertAreEqual(WmtsMapData expected, WmtsMapData actual)
{
- var control = ShowValidWmtsLocationControl();
+ if (expected == null)
+ {
+ Assert.IsNull(actual);
+ return;
+ }
+ Assert.AreEqual(expected.Name, actual.Name);
+ Assert.AreEqual(expected.PreferredFormat, actual.PreferredFormat);
+ Assert.AreEqual(expected.SelectedCapabilityIdentifier, actual.SelectedCapabilityIdentifier);
+ Assert.AreEqual(expected.SourceCapabilitiesUrl, actual.SourceCapabilitiesUrl);
+ }
+
+ private WmtsLocationControl ShowFullyConfiguredWmtsLocationControl()
+ {
+ WmtsLocationControl control = ShowValidWmtsLocationControl();
Form form = control.FindForm();
var capabilities = new List
@@ -890,7 +1021,7 @@
return control;
}
- private static WmtsLocationControl ShowValidWmtsLocationControl()
+ private WmtsLocationControl ShowValidWmtsLocationControl()
{
var form = new Form();
var control = new WmtsLocationControl(null);