Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.cs =================================================================== diff -u -r1be704f7fb39169579e4a15ca74161314347730b -r53b1e8349a2eb01d0bb64a7923cbecf694358cda --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.cs (.../LocationsView.cs) (revision 1be704f7fb39169579e4a15ca74161314347730b) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.cs (.../LocationsView.cs) (revision 53b1e8349a2eb01d0bb64a7923cbecf694358cda) @@ -38,6 +38,7 @@ { private const int calculateColumnIndex = 0; private bool updatingDataSource; + private bool updatingControls; public event EventHandler SelectionChanged; /// @@ -52,13 +53,7 @@ public abstract object Data { get; set; } - public object Selection - { - get - { - return CreateSelectedItemFromCurrentRow(); - } - } + public object Selection { get; private set; } protected override void OnLoad(EventArgs e) { @@ -176,17 +171,25 @@ { dataGridViewControl.AddCurrentCellChangedHandler(DataGridViewOnCurrentCellChangedHandler); dataGridViewControl.AddCellValueChangedHandler(DataGridViewCellValueChanged); + illustrationPointsControl.SelectionChanged += IllustrationPointsControlOnSelectionChanged; } private void OnSelectionChanged() { SelectionChanged?.Invoke(this, new EventArgs()); - - illustrationPointsControl.Data = GetGeneralResultSubMechanismIllustrationPoints(); } #region Event handling + private void IllustrationPointsControlOnSelectionChanged(object sender, EventArgs eventArgs) + { + if (!updatingControls) + { + Selection = illustrationPointsControl.Selection; + OnSelectionChanged(); + } + } + private void DataGridViewCellValueChanged(object sender, DataGridViewCellEventArgs e) { if (!updatingDataSource && e.ColumnIndex == calculateColumnIndex) @@ -197,7 +200,14 @@ private void DataGridViewOnCurrentCellChangedHandler(object sender, EventArgs e) { + updatingControls = true; + + illustrationPointsControl.Data = GetGeneralResultSubMechanismIllustrationPoints(); + + Selection = CreateSelectedItemFromCurrentRow(); OnSelectionChanged(); + + updatingControls = false; } /// Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs =================================================================== diff -u -r1ab0201beb5f403186b715a0ed4e30bcf7f78f9a -r53b1e8349a2eb01d0bb64a7923cbecf694358cda --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 1ab0201beb5f403186b715a0ed4e30bcf7f78f9a) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 53b1e8349a2eb01d0bb64a7923cbecf694358cda) @@ -271,7 +271,7 @@ protected override object CreateSelectedItemFromCurrentRow() { - throw new NotImplementedException(); + return null; } protected override GeneralResultSubMechanismIllustrationPoint GetGeneralResultSubMechanismIllustrationPoints() Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/LocationsViewTest.cs =================================================================== diff -u -r8ba742d2139563c9571e32f074c7c4b3077f45ee -r53b1e8349a2eb01d0bb64a7923cbecf694358cda --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/LocationsViewTest.cs (.../LocationsViewTest.cs) (revision 8ba742d2139563c9571e32f074c7c4b3077f45ee) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/LocationsViewTest.cs (.../LocationsViewTest.cs) (revision 53b1e8349a2eb01d0bb64a7923cbecf694358cda) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; @@ -28,6 +29,7 @@ using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; using Ringtoets.Common.Forms.Views; namespace Ringtoets.Common.Forms.Test.Views @@ -95,7 +97,7 @@ TestLocationsView view = ShowTestCalculatableView(); // Assert - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + DataGridView dataGridView = GetDataGridView(); Assert.AreEqual(1, dataGridView.ColumnCount); var calculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[calculateColumnIndex]; @@ -112,13 +114,10 @@ // Given TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); - var createdSelection = new object(); - view.CreateForSelection = createdSelection; - var selectionChangedCount = 0; view.SelectionChanged += (sender, args) => selectionChangedCount++; - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + DataGridView dataGridView = GetDataGridView(); // When dataGridView.CurrentCell = dataGridView.Rows[1].Cells[calculateColumnIndex]; @@ -129,28 +128,74 @@ } [Test] - public void Selection_Always_ReturnsCreatedSelectionObject() + public void GivenFullyConfiguredView_WhenSelectingCellInRow_ThenIllustrationPointsUpdated() { - // Setup + // Given + ShowFullyConfiguredTestCalculatableView(); + + DataGridView dataGridView = GetDataGridView(); + DataGridView illustrationPointDataGridView = GetIllustrationPointDataGridView(); + + // Precondition + Assert.AreEqual(2, illustrationPointDataGridView.Rows.Count); + + // When + dataGridView.CurrentCell = dataGridView.Rows[1].Cells[calculateColumnIndex]; + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); + + // Then + Assert.AreEqual(3, illustrationPointDataGridView.Rows.Count); + } + + [Test] + public void GivenFullyConfiguredView_WhenSelectingRowInLocationsTable_ThenReturnSelectedLocation() + { + // Given TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); - var createdSelection = new object(); - view.CreateForSelection = createdSelection; + DataGridView dataGridView = GetDataGridView(); + DataGridViewRow currentRow = dataGridView.Rows[1]; - // Call + TestCalculatableObject calculatableObject = ((TestCalculatableRow) currentRow.DataBoundItem).CalculatableObject; + + // When + dataGridView.CurrentCell = currentRow.Cells[calculateColumnIndex]; + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); object selection = view.Selection; - // Assert - Assert.AreSame(createdSelection, selection); + // Then + Assert.AreSame(calculatableObject, selection); } [Test] + public void GivenFullyConfiguredView_WhenSelectingRowInIllustrationPointsTable_ThenReturnSelectedIllustrationPoint() + { + // Given + TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); + + DataGridView dataGridView = GetDataGridView(); + DataGridView illustrationPointDataGridView = GetIllustrationPointDataGridView(); + + DataGridViewRow currentRow = illustrationPointDataGridView.Rows[1]; + + TestCalculatableObject calculatableObject = ((TestCalculatableRow) dataGridView.Rows[0].DataBoundItem).CalculatableObject; + + // When + illustrationPointDataGridView.CurrentCell = currentRow.Cells[calculateColumnIndex]; + EventHelper.RaiseEvent(illustrationPointDataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); + object selection = view.Selection; + + // Then + Assert.AreSame(calculatableObject.GeneralResult.TopLevelSubMechanismIllustrationPoints.ElementAt(1), selection); + } + + [Test] public void SelectAllButton_SelectAllButtonClicked_AllCalculatableItemsSelected() { // Setup - TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); + ShowFullyConfiguredTestCalculatableView(); - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + DataGridView dataGridView = GetDataGridView(); DataGridViewRowCollection rows = dataGridView.Rows; var button = new ButtonTester("SelectAllButton", testForm); @@ -170,9 +215,9 @@ public void DeselectAllButton_AllCalculatableItemsSelectedDeselectAllButtonClicked_AllCalculatableItemsNotSelected() { // Setup - TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); + ShowFullyConfiguredTestCalculatableView(); - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + DataGridView dataGridView = GetDataGridView(); var button = new ButtonTester("DeselectAllButton", testForm); DataGridViewRowCollection rows = dataGridView.Rows; @@ -211,7 +256,7 @@ { // Given TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + DataGridView dataGridView = GetDataGridView(); // When dataGridView.Rows[0].Cells[calculateColumnIndex].Value = true; @@ -229,7 +274,7 @@ // Setup TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true)[0]; + DataGridView dataGridView = GetDataGridView(); DataGridViewRowCollection rows = dataGridView.Rows; rows[0].Cells[calculateColumnIndex].Value = true; @@ -245,6 +290,27 @@ Assert.AreEqual(expectedObject, view.ObjectsToCalculate.First()); } + private DataGridView GetDataGridView() + { + return GetControls("DataGridView").First(); + } + + private DataGridView GetIllustrationPointDataGridView() + { + return GetControls("DataGridView").Last(); + } + + /// + /// Gets the controls by name. + /// + /// The name of the controls. + /// The found control. + /// Thrown when is null or empty. + private IEnumerable GetControls(string controlName) where TView : Control + { + return testForm.Controls.Find(controlName, true).Cast(); + } + private TestLocationsView ShowTestCalculatableView() { var view = new TestLocationsView(); @@ -259,8 +325,44 @@ TestLocationsView view = ShowTestCalculatableView(); view.Data = new[] { - new TestCalculatableObject(), - new TestCalculatableObject() + new TestCalculatableObject + { + GeneralResult = new GeneralResultSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), + Enumerable.Empty(), + new[] + { + new TopLevelSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), "Regular", + new SubMechanismIllustrationPoint("Point 1", Enumerable.Empty(), + Enumerable.Empty(), 0.9)), + new TopLevelSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), "Open", + new SubMechanismIllustrationPoint("Point 2", Enumerable.Empty(), + Enumerable.Empty(), 0.7)) + }) + }, + new TestCalculatableObject + { + GeneralResult = new GeneralResultSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), + Enumerable.Empty(), + new[] + { + new TopLevelSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), "Regular", + new SubMechanismIllustrationPoint("Point 1", Enumerable.Empty(), + Enumerable.Empty(), 0.9)), + new TopLevelSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), "Open", + new SubMechanismIllustrationPoint("Point 2", Enumerable.Empty(), + Enumerable.Empty(), 0.7)), + new TopLevelSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), "Closed", + new SubMechanismIllustrationPoint("Point 3", Enumerable.Empty(), + Enumerable.Empty(), 0.8)) + }) + } }; return view; } @@ -276,6 +378,8 @@ private class TestCalculatableObject { public bool IsChecked { get; } + + public GeneralResultSubMechanismIllustrationPoint GeneralResult { get; set; } } private class TestLocationsView : LocationsView @@ -300,13 +404,11 @@ } } - public object CreateForSelection { private get; set; } - public IEnumerable ObjectsToCalculate { get; private set; } protected override object CreateSelectedItemFromCurrentRow() { - return CreateForSelection; + return ((TestCalculatableRow) dataGridViewControl.CurrentRow?.DataBoundItem)?.CalculatableObject; } protected override void SetDataSource() @@ -324,7 +426,9 @@ protected override GeneralResultSubMechanismIllustrationPoint GetGeneralResultSubMechanismIllustrationPoints() { - return null; + TestCalculatableObject calculatableObject = ((TestCalculatableRow) dataGridViewControl.CurrentRow?.DataBoundItem)?.CalculatableObject; + + return calculatableObject?.GeneralResult; } } } Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -rca13ac94cb4308335c7a44bd15aa903eec98b308 -r53b1e8349a2eb01d0bb64a7923cbecf694358cda --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs) (revision ca13ac94cb4308335c7a44bd15aa903eec98b308) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs) (revision 53b1e8349a2eb01d0bb64a7923cbecf694358cda) @@ -87,6 +87,26 @@ } [Test] + public void GivenFullyConfiguredView_WhenSelectingRowInLocationsTable_ThenReturnSelectedLocation() + { + // Given + GrassCoverErosionOutwardsDesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); + + DataGridView dataGridView = GetDataGridView(); + DataGridViewRow currentRow = dataGridView.Rows[1]; + + HydraulicBoundaryLocation location = ((HydraulicBoundaryLocationRow)currentRow.DataBoundItem).CalculatableObject; + + // When + dataGridView.CurrentCell = currentRow.Cells[0]; + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); + var selection = view.Selection as GrassCoverErosionOutwardsDesignWaterLevelLocationContext; + + // Then + Assert.AreSame(location, selection.HydraulicBoundaryLocation); + } + + [Test] public void Selection_WithoutLocations_ReturnsNull() { // Call @@ -98,25 +118,6 @@ } [Test] - public void Selection_WithLocations_ReturnsSelectedLocationWrappedInContext() - { - // Call - GrassCoverErosionOutwardsDesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - - DataGridViewControl dataGridView = GetDataGridViewControl(); - DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; - selectedLocationRow.Cells[0].Value = true; - - // Assert - var selection = view.Selection as GrassCoverErosionOutwardsDesignWaterLevelLocationContext; - var dataBoundItem = selectedLocationRow.DataBoundItem as HydraulicBoundaryLocationRow; - - Assert.NotNull(selection); - Assert.NotNull(dataBoundItem); - Assert.AreSame(dataBoundItem.CalculatableObject, selection.HydraulicBoundaryLocation); - } - - [Test] public void Selection_LocationWithoutOutput_IllustrationPointsControlDataSetToNull() { // Setup Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs =================================================================== diff -u -rca13ac94cb4308335c7a44bd15aa903eec98b308 -r53b1e8349a2eb01d0bb64a7923cbecf694358cda --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs) (revision ca13ac94cb4308335c7a44bd15aa903eec98b308) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs) (revision 53b1e8349a2eb01d0bb64a7923cbecf694358cda) @@ -87,6 +87,26 @@ } [Test] + public void GivenFullyConfiguredView_WhenSelectingRowInLocationsTable_ThenReturnSelectedLocation() + { + // Given + GrassCoverErosionOutwardsWaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); + + DataGridView dataGridView = GetDataGridView(); + DataGridViewRow currentRow = dataGridView.Rows[1]; + + HydraulicBoundaryLocation location = ((HydraulicBoundaryLocationRow)currentRow.DataBoundItem).CalculatableObject; + + // When + dataGridView.CurrentCell = currentRow.Cells[0]; + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); + var selection = view.Selection as GrassCoverErosionOutwardsWaveHeightLocationContext; + + // Then + Assert.AreSame(location, selection.HydraulicBoundaryLocation); + } + + [Test] public void Selection_WithoutLocations_ReturnsNull() { // Call @@ -98,25 +118,6 @@ } [Test] - public void Selection_WithLocations_ReturnsSelectedLocationWrappedInContext() - { - // Call - GrassCoverErosionOutwardsWaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); - - DataGridViewControl dataGridView = GetDataGridViewControl(); - DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; - selectedLocationRow.Cells[0].Value = true; - - // Assert - var selection = view.Selection as GrassCoverErosionOutwardsWaveHeightLocationContext; - var dataBoundItem = selectedLocationRow.DataBoundItem as HydraulicBoundaryLocationRow; - - Assert.NotNull(selection); - Assert.NotNull(dataBoundItem); - Assert.AreSame(dataBoundItem.CalculatableObject, selection.HydraulicBoundaryLocation); - } - - [Test] public void Selection_LocationWithoutOutput_IllustrationPointsControlDataSetToNull() { // Setup Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r6cdf02ac497b3bab4f7f955efac588545f5b8986 -r53b1e8349a2eb01d0bb64a7923cbecf694358cda --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 6cdf02ac497b3bab4f7f955efac588545f5b8986) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 53b1e8349a2eb01d0bb64a7923cbecf694358cda) @@ -51,6 +51,7 @@ False ..\..\..\..\lib\NUnitForms.dll + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll True Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -rca13ac94cb4308335c7a44bd15aa903eec98b308 -r53b1e8349a2eb01d0bb64a7923cbecf694358cda --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision ca13ac94cb4308335c7a44bd15aa903eec98b308) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 53b1e8349a2eb01d0bb64a7923cbecf694358cda) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Windows.Controls; using System.Windows.Forms; using Core.Common.Base; using Core.Common.Base.Geometry; @@ -40,6 +41,8 @@ using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Views; using Ringtoets.Integration.Service.MessageProviders; +using Button = System.Windows.Forms.Button; +using Control = System.Windows.Forms.Control; namespace Ringtoets.Integration.Forms.Test.Views { @@ -79,6 +82,26 @@ } [Test] + public void GivenFullyConfiguredView_WhenSelectingRowInLocationsTable_ThenReturnSelectedLocation() + { + // Given + DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); + + DataGridView dataGridView = GetDataGridView(); + DataGridViewRow currentRow = dataGridView.Rows[1]; + + HydraulicBoundaryLocation location = ((HydraulicBoundaryLocationRow)currentRow.DataBoundItem).CalculatableObject; + + // When + dataGridView.CurrentCell = currentRow.Cells[0]; + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); + var selection = view.Selection as DesignWaterLevelLocationContext; + + // Then + Assert.AreSame(location, selection.HydraulicBoundaryLocation); + } + + [Test] public void Selection_WithoutLocations_ReturnsNull() { // Call @@ -90,24 +113,6 @@ } [Test] - public void Selection_WithLocations_ReturnsSelectedLocationWrappedInContext() - { - // Call - DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - DataGridViewControl dataGridView = GetDataGridViewControl(); - DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; - selectedLocationRow.Cells[0].Value = true; - - // Assert - var selection = view.Selection as DesignWaterLevelLocationContext; - var dataBoundItem = selectedLocationRow.DataBoundItem as HydraulicBoundaryLocationRow; - - Assert.NotNull(selection); - Assert.NotNull(dataBoundItem); - Assert.AreSame(dataBoundItem.CalculatableObject, selection.HydraulicBoundaryLocation); - } - - [Test] public void Selection_LocationWithoutOutput_IllustrationPointsControlDataSetToNull() { // Setup @@ -457,8 +462,8 @@ HydraulicBoundaryDatabase = new TestHydraulicBoundaryDatabase() }; - view.Data = assessmentSection.HydraulicBoundaryDatabase.Locations; view.AssessmentSection = assessmentSection; + view.Data = assessmentSection.HydraulicBoundaryDatabase.Locations; return view; } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs =================================================================== diff -u -rca13ac94cb4308335c7a44bd15aa903eec98b308 -r53b1e8349a2eb01d0bb64a7923cbecf694358cda --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision ca13ac94cb4308335c7a44bd15aa903eec98b308) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 53b1e8349a2eb01d0bb64a7923cbecf694358cda) @@ -77,6 +77,26 @@ } [Test] + public void GivenFullyConfiguredView_WhenSelectingRowInLocationsTable_ThenReturnSelectedLocation() + { + // Given + WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); + + DataGridView dataGridView = GetDataGridView(); + DataGridViewRow currentRow = dataGridView.Rows[1]; + + HydraulicBoundaryLocation location = ((HydraulicBoundaryLocationRow)currentRow.DataBoundItem).CalculatableObject; + + // When + dataGridView.CurrentCell = currentRow.Cells[0]; + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); + var selection = view.Selection as WaveHeightLocationContext; + + // Then + Assert.AreSame(location, selection.HydraulicBoundaryLocation); + } + + [Test] public void Selection_WithoutLocations_ReturnsNull() { // Call @@ -88,25 +108,6 @@ } [Test] - public void Selection_WithLocations_ReturnsSelectedLocationWrappedInContext() - { - // Call - WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); - - DataGridViewControl dataGridView = GetDataGridViewControl(); - DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; - selectedLocationRow.Cells[0].Value = true; - - // Assert - var selection = view.Selection as WaveHeightLocationContext; - var dataBoundItem = selectedLocationRow.DataBoundItem as HydraulicBoundaryLocationRow; - - Assert.NotNull(selection); - Assert.NotNull(dataBoundItem); - Assert.AreSame(dataBoundItem.CalculatableObject, selection.HydraulicBoundaryLocation); - } - - [Test] public void Selection_LocationWithoutOutput_IllustrationPointsControlDataSetToNull() { // Setup @@ -451,8 +452,8 @@ HydraulicBoundaryDatabase = new TestHydraulicBoundaryDatabase() }; - view.Data = assessmentSection.HydraulicBoundaryDatabase.Locations; view.AssessmentSection = assessmentSection; + view.Data = assessmentSection.HydraulicBoundaryDatabase.Locations; return view; }