Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/LocationsViewDataSynchronisationTester.cs =================================================================== diff -u -ra71e876edf0469b119b16d801a23e159e8f0986c -rd19a65425aed738d0dd4a7c4805501ec0c1863aa --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/LocationsViewDataSynchronisationTester.cs (.../LocationsViewDataSynchronisationTester.cs) (revision a71e876edf0469b119b16d801a23e159e8f0986c) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/LocationsViewDataSynchronisationTester.cs (.../LocationsViewDataSynchronisationTester.cs) (revision d19a65425aed738d0dd4a7c4805501ec0c1863aa) @@ -152,6 +152,29 @@ } [Test] + public void GivenFullyConfiguredViewWithLocationSelection_WhenOutputUpdated_ThenSelectionPreserved() + { + // Given + LocationsView view = ShowFullyConfiguredLocationsView(testForm); + + DataGridView locationsDataGridView = GetLocationsDataGridView(); + locationsDataGridView.CurrentCell = locationsDataGridView.Rows[4].Cells[0]; + + // Precondition + DataGridViewRow currentLocationRow = GetLocationsDataGridViewControl().CurrentRow; + Assert.AreEqual(4, currentLocationRow.Index); + Assert.AreEqual(GetLocationSelection(view, currentLocationRow.DataBoundItem), view.Selection); + + // When + AddLocationOutputAndNotifyObservers(view); + + // Then + currentLocationRow = GetLocationsDataGridViewControl().CurrentRow; + Assert.AreEqual(4, currentLocationRow.Index); + Assert.AreEqual(GetLocationSelection(view, currentLocationRow.DataBoundItem), view.Selection); + } + + [Test] public void GivenFullyConfiguredViewWithIllustrationPointSelection_WhenOutputCleared_ThenSelectionSetToLocation() { // Given @@ -177,6 +200,35 @@ Assert.AreEqual(GetLocationSelection(view, locationsDataGridView.CurrentRow?.DataBoundItem), view.Selection); } + [Test] + public void GivenFullyConfiguredViewWithIllustrationPointSelection_WhenOutputUpdated_ThenSelectionPreserved() + { + // Given + LocationsView view = ShowFullyConfiguredLocationsView(testForm); + + DataGridView locationsDataGridView = GetLocationsDataGridView(); + locationsDataGridView.CurrentCell = locationsDataGridView.Rows[4].Cells[0]; + DataGridView illustrationPointsDataGridView = GetIllustrationPointsDataGridView(); + illustrationPointsDataGridView.CurrentCell = illustrationPointsDataGridView.Rows[1].Cells[0]; + + // Precondition + Assert.AreEqual(4, locationsDataGridView.CurrentRow?.Index); + Assert.AreEqual(1, illustrationPointsDataGridView.CurrentRow?.Index); + var selection = view.Selection as SelectedTopLevelSubMechanismIllustrationPoint; + Assert.IsNotNull(selection); + Assert.AreSame(GetIllustrationPointsControl().Data.ElementAt(1).Source, selection.TopLevelSubMechanismIllustrationPoint); + + // When + AddLocationOutputAndNotifyObservers(view); + + // Then + Assert.AreEqual(4, locationsDataGridView.CurrentRow?.Index); + Assert.AreEqual(1, illustrationPointsDataGridView.CurrentRow?.Index); + selection = view.Selection as SelectedTopLevelSubMechanismIllustrationPoint; + Assert.IsNotNull(selection); + Assert.AreSame(GetIllustrationPointsControl().Data.ElementAt(1).Source, selection.TopLevelSubMechanismIllustrationPoint); + } + /// /// Gets the index of the column containing the locations output. /// @@ -213,6 +265,12 @@ /// The locations view involved. protected abstract void ClearLocationOutputAndNotifyObservers(LocationsView view); + /// + /// Method for adding some location output as well as notifying the observers. + /// + /// The locations view involved. + protected abstract void AddLocationOutputAndNotifyObservers(LocationsView view); + private DataGridView GetLocationsDataGridView() { return ControlTestHelper.GetDataGridView(testForm, "DataGridView"); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -ra71e876edf0469b119b16d801a23e159e8f0986c -rd19a65425aed738d0dd4a7c4805501ec0c1863aa --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs) (revision a71e876edf0469b119b16d801a23e159e8f0986c) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs) (revision d19a65425aed738d0dd4a7c4805501ec0c1863aa) @@ -487,6 +487,14 @@ locations.ForEach(loc => loc.DesignWaterLevelCalculation.Output = null); locations.NotifyObservers(); } + + protected override void AddLocationOutputAndNotifyObservers(LocationsView view) + { + var locations = (ObservableList) view.Data; + + locations.First().DesignWaterLevelCalculation.Output = new TestHydraulicBoundaryLocationOutput(new TestGeneralResultSubMechanismIllustrationPoint()); + locations.NotifyObservers(); + } } private static IEnumerable CreateControlItems( Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs =================================================================== diff -u -ra71e876edf0469b119b16d801a23e159e8f0986c -rd19a65425aed738d0dd4a7c4805501ec0c1863aa --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs) (revision a71e876edf0469b119b16d801a23e159e8f0986c) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs) (revision d19a65425aed738d0dd4a7c4805501ec0c1863aa) @@ -486,6 +486,14 @@ locations.ForEach(loc => loc.WaveHeightCalculation.Output = null); locations.NotifyObservers(); } + + protected override void AddLocationOutputAndNotifyObservers(LocationsView view) + { + var locations = (ObservableList) view.Data; + + locations.First().WaveHeightCalculation.Output = new TestHydraulicBoundaryLocationOutput(new TestGeneralResultSubMechanismIllustrationPoint()); + locations.NotifyObservers(); + } } private static IEnumerable CreateControlItems( Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -ra71e876edf0469b119b16d801a23e159e8f0986c -rd19a65425aed738d0dd4a7c4805501ec0c1863aa --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision a71e876edf0469b119b16d801a23e159e8f0986c) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision d19a65425aed738d0dd4a7c4805501ec0c1863aa) @@ -372,6 +372,14 @@ assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.DesignWaterLevelCalculation.Output = null); assessmentSection.NotifyObservers(); } + + protected override void AddLocationOutputAndNotifyObservers(LocationsView view) + { + IAssessmentSection assessmentSection = view.AssessmentSection; + + assessmentSection.HydraulicBoundaryDatabase.Locations.First().DesignWaterLevelCalculation.Output = new TestHydraulicBoundaryLocationOutput(new TestGeneralResultSubMechanismIllustrationPoint()); + assessmentSection.NotifyObservers(); + } } private static IEnumerable CreateControlItems( Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs =================================================================== diff -u -ra71e876edf0469b119b16d801a23e159e8f0986c -rd19a65425aed738d0dd4a7c4805501ec0c1863aa --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision a71e876edf0469b119b16d801a23e159e8f0986c) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision d19a65425aed738d0dd4a7c4805501ec0c1863aa) @@ -364,6 +364,14 @@ assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.WaveHeightCalculation.Output = null); assessmentSection.NotifyObservers(); } + + protected override void AddLocationOutputAndNotifyObservers(LocationsView view) + { + IAssessmentSection assessmentSection = view.AssessmentSection; + + assessmentSection.HydraulicBoundaryDatabase.Locations.First().WaveHeightCalculation.Output = new TestHydraulicBoundaryLocationOutput(new TestGeneralResultSubMechanismIllustrationPoint()); + assessmentSection.NotifyObservers(); + } } private static IEnumerable CreateControlItems(