Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/HydraulicBoundaryLocationsView.cs =================================================================== diff -u -r6ef4dd653a4a5922e1d7e06e38fbdd4b9971644c -r4b557a57e20d32dc01a1bec3ed076ee85213b069 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/HydraulicBoundaryLocationsView.cs (.../HydraulicBoundaryLocationsView.cs) (revision 6ef4dd653a4a5922e1d7e06e38fbdd4b9971644c) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/HydraulicBoundaryLocationsView.cs (.../HydraulicBoundaryLocationsView.cs) (revision 4b557a57e20d32dc01a1bec3ed076ee85213b069) @@ -74,11 +74,6 @@ /// public IHydraulicBoundaryLocationCalculationGuiService CalculationGuiService { get; set; } - /// - /// Gets the . - /// - public IAssessmentSection AssessmentSection { get; } - protected override void InitializeDataGridView() { base.InitializeDataGridView(); Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.cs =================================================================== diff -u -r6ef4dd653a4a5922e1d7e06e38fbdd4b9971644c -r4b557a57e20d32dc01a1bec3ed076ee85213b069 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.cs (.../LocationsView.cs) (revision 6ef4dd653a4a5922e1d7e06e38fbdd4b9971644c) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/LocationsView.cs (.../LocationsView.cs) (revision 4b557a57e20d32dc01a1bec3ed076ee85213b069) @@ -25,6 +25,7 @@ using System.Windows.Forms; using Core.Common.Controls.Views; using Core.Common.Utils.Extensions; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.Properties; @@ -52,6 +53,11 @@ InitializeEventHandlers(); } + /// + /// Gets or sets the . + /// + public IAssessmentSection AssessmentSection { get; protected set; } + public object Selection { get; private set; } public abstract object Data { get; set; } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/LocationsViewDataSynchronisationTester.cs =================================================================== diff -u -r0f68d5b3472a122ffda0030d2f78023ae34a6b6f -r4b557a57e20d32dc01a1bec3ed076ee85213b069 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/LocationsViewDataSynchronisationTester.cs (.../LocationsViewDataSynchronisationTester.cs) (revision 0f68d5b3472a122ffda0030d2f78023ae34a6b6f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/LocationsViewDataSynchronisationTester.cs (.../LocationsViewDataSynchronisationTester.cs) (revision 4b557a57e20d32dc01a1bec3ed076ee85213b069) @@ -92,20 +92,71 @@ CollectionAssert.IsNotEmpty(illustrationPointsControl.Data); } + [Test] + public void GivenFullyConfiguredView_WhenLocationOutputCleared_DataGridViewUpdatedAndSelectionPreserved() + { + // Given + LocationsView view = ShowFullyConfiguredLocationsView(testForm); + + // Precondition + DataGridView dataGridView = GetDataGridView(); + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(5, rows.Count); + Assert.AreEqual("-", rows[0].Cells[OutputColumnIndex].FormattedValue); + Assert.AreNotEqual("-", rows[1].Cells[OutputColumnIndex].FormattedValue); + Assert.AreEqual("-", rows[2].Cells[OutputColumnIndex].FormattedValue); + Assert.AreEqual("-", rows[3].Cells[OutputColumnIndex].FormattedValue); + Assert.AreNotEqual("-", rows[4].Cells[OutputColumnIndex].FormattedValue); + + var refreshed = false; + dataGridView.Invalidated += (sender, args) => refreshed = true; + + // When + ClearLocationOutputAndNotifyObservers(view); + + // Then + Assert.IsTrue(refreshed); + Assert.AreEqual(5, rows.Count); + Assert.AreEqual("-", rows[0].Cells[OutputColumnIndex].FormattedValue); + Assert.AreEqual("-", rows[1].Cells[OutputColumnIndex].FormattedValue); + Assert.AreEqual("-", rows[2].Cells[OutputColumnIndex].FormattedValue); + Assert.AreEqual("-", rows[3].Cells[OutputColumnIndex].FormattedValue); + Assert.AreEqual("-", rows[4].Cells[OutputColumnIndex].FormattedValue); + } + /// + /// Gets the index of the column containing the locations output. + /// + protected abstract int OutputColumnIndex { get; } + + /// /// Method for showing a fully configured locations view. /// /// The form to use for showing the view. /// /// The view should contain the following location row data: /// /// Row 1: location without output - /// Row 2: location with output but without general result - /// Row 4: location with output containing a general result + /// Row 2: location with design water level output (but without general result) + /// Row 3: location with wave height output (but without general result) + /// Row 4: location with flag for parsing the general result set to true + /// Row 5: location with output containing a general result /// /// - protected abstract void ShowFullyConfiguredLocationsView(Form form); + /// The fully configured locations view. + protected abstract LocationsView ShowFullyConfiguredLocationsView(Form form); + /// + /// Method for clearing all location output as well as notifying the observers. + /// + /// The view involved. + protected abstract void ClearLocationOutputAndNotifyObservers(LocationsView view); + + private DataGridView GetDataGridView() + { + return ControlTestHelper.GetDataGridView(testForm, "DataGridView"); + } + private DataGridViewControl GetDataGridViewControl() { return ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -r0f68d5b3472a122ffda0030d2f78023ae34a6b6f -r4b557a57e20d32dc01a1bec3ed076ee85213b069 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs) (revision 0f68d5b3472a122ffda0030d2f78023ae34a6b6f) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs) (revision 4b557a57e20d32dc01a1bec3ed076ee85213b069) @@ -335,44 +335,6 @@ } [Test] - public void DesignWaterLevelLocationsView_EachHydraulicBoundaryLocationUpdated_DataGridViewRefreshedWithNewValues() - { - // Setup - var assessmentSection = mockRepository.Stub(); - mockRepository.ReplayAll(); - - GrassCoverErosionOutwardsDesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(assessmentSection, testForm); - var locations = (ObservableList) view.Data; - - // Precondition - DataGridView dataGridView = GetDataGridView(); - DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(5, rows.Count); - Assert.AreEqual("-", rows[0].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual(1.23.ToString(CultureInfo.CurrentCulture), rows[1].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[2].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[3].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual(1.01.ToString(CultureInfo.CurrentCulture), rows[4].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - - locations.ForEach(loc => loc.DesignWaterLevelCalculation.Output = null); - - var refreshed = false; - dataGridView.Invalidated += (sender, args) => refreshed = true; - - // Call - locations.NotifyObservers(); - - // Assert - Assert.IsTrue(refreshed); - Assert.AreEqual(5, rows.Count); - Assert.AreEqual("-", rows[0].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[1].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[2].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[3].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[4].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - } - - [Test] [TestCase(true)] [TestCase(false)] public void CalculateForSelectedButton_OneSelected_CallsCalculateDesignWaterLevelsSelectionNotChanged(bool isSuccessful) @@ -499,10 +461,26 @@ [TestFixture] public class DataSynchronisationTester : LocationsViewDataSynchronisationTester { - protected override void ShowFullyConfiguredLocationsView(Form form) + protected override int OutputColumnIndex { - ShowFullyConfiguredDesignWaterLevelLocationsView(new ObservableTestAssessmentSectionStub(), form); + get + { + return locationDesignWaterlevelColumnIndex; + } } + + protected override LocationsView ShowFullyConfiguredLocationsView(Form form) + { + return ShowFullyConfiguredDesignWaterLevelLocationsView(new ObservableTestAssessmentSectionStub(), form); + } + + protected override void ClearLocationOutputAndNotifyObservers(LocationsView view) + { + var locations = (ObservableList) view.Data; + + locations.ForEach(loc => loc.DesignWaterLevelCalculation.Output = null); + locations.NotifyObservers(); + } } private static IEnumerable CreateControlItems( Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs =================================================================== diff -u -r0f68d5b3472a122ffda0030d2f78023ae34a6b6f -r4b557a57e20d32dc01a1bec3ed076ee85213b069 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs) (revision 0f68d5b3472a122ffda0030d2f78023ae34a6b6f) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs) (revision 4b557a57e20d32dc01a1bec3ed076ee85213b069) @@ -335,44 +335,6 @@ } [Test] - public void WaveHeightLocationsView_EachHydraulicBoundaryLocationUpdated_DataGridViewRefreshedWithNewValues() - { - // Setup - var assessmentSection = mockRepository.Stub(); - mockRepository.ReplayAll(); - - GrassCoverErosionOutwardsWaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(assessmentSection, testForm); - var locations = (ObservableList) view.Data; - - // Precondition - DataGridView dataGridView = GetDataGridView(); - DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(5, rows.Count); - Assert.AreEqual("-", rows[0].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual(1.23.ToString(CultureInfo.CurrentCulture), rows[1].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[2].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[3].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual(1.01.ToString(CultureInfo.CurrentCulture), rows[4].Cells[locationWaveHeightColumnIndex].FormattedValue); - - locations.ForEach(loc => loc.WaveHeightCalculation.Output = null); - - var refreshed = false; - dataGridView.Invalidated += (sender, args) => refreshed = true; - - // Call - locations.NotifyObservers(); - - // Assert - Assert.IsTrue(refreshed); - Assert.AreEqual(5, rows.Count); - Assert.AreEqual("-", rows[0].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[1].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[2].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[3].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[4].Cells[locationWaveHeightColumnIndex].FormattedValue); - } - - [Test] [TestCase(true)] [TestCase(false)] public void CalculateForSelectedButton_OneSelected_CallsCalculateWaveHeightsSelectionNotChanged(bool isSuccessful) @@ -498,10 +460,26 @@ [TestFixture] public class DataSynchronisationTester : LocationsViewDataSynchronisationTester { - protected override void ShowFullyConfiguredLocationsView(Form form) + protected override int OutputColumnIndex { - ShowFullyConfiguredWaveHeightLocationsView(new ObservableTestAssessmentSectionStub(), form); + get + { + return locationWaveHeightColumnIndex; + } } + + protected override LocationsView ShowFullyConfiguredLocationsView(Form form) + { + return ShowFullyConfiguredWaveHeightLocationsView(new ObservableTestAssessmentSectionStub(), form); + } + + protected override void ClearLocationOutputAndNotifyObservers(LocationsView view) + { + var locations = (ObservableList) view.Data; + + locations.ForEach(loc => loc.WaveHeightCalculation.Output = null); + locations.NotifyObservers(); + } } private static IEnumerable CreateControlItems( Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -r0f68d5b3472a122ffda0030d2f78023ae34a6b6f -r4b557a57e20d32dc01a1bec3ed076ee85213b069 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 0f68d5b3472a122ffda0030d2f78023ae34a6b6f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 4b557a57e20d32dc01a1bec3ed076ee85213b069) @@ -201,41 +201,6 @@ } [Test] - public void DesignWaterLevelLocationsView_AssessmentSectionUpdated_DataGridViewCorrectlyUpdated() - { - // Setup - DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(testForm); - IAssessmentSection assessmentSection = view.AssessmentSection; - - // Precondition - DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); - DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(5, rows.Count); - Assert.AreEqual("-", rows[0].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual(1.23.ToString(CultureInfo.CurrentCulture), rows[1].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[2].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[3].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual(1.01.ToString(CultureInfo.CurrentCulture), rows[4].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - - assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.DesignWaterLevelCalculation.Output = null); - - var refreshed = false; - dataGridView.Invalidated += (sender, args) => refreshed = true; - - // Call - assessmentSection.NotifyObservers(); - - // Assert - Assert.IsTrue(refreshed); - Assert.AreEqual(5, rows.Count); - Assert.AreEqual("-", rows[0].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[1].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[2].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[3].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[4].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); - } - - [Test] public void DesignWaterLevelLocationsView_HydraulicBoundaryDatabaseUpdated_DataGridViewCorrectlyUpdated() { // Setup @@ -379,10 +344,26 @@ [TestFixture] public class DataSynchronisationTester : LocationsViewDataSynchronisationTester { - protected override void ShowFullyConfiguredLocationsView(Form form) + protected override int OutputColumnIndex { - ShowFullyConfiguredDesignWaterLevelLocationsView(form); + get + { + return locationDesignWaterlevelColumnIndex; + } } + + protected override LocationsView ShowFullyConfiguredLocationsView(Form form) + { + return ShowFullyConfiguredDesignWaterLevelLocationsView(form); + } + + protected override void ClearLocationOutputAndNotifyObservers(LocationsView view) + { + IAssessmentSection assessmentSection = view.AssessmentSection; + + assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.DesignWaterLevelCalculation.Output = null); + assessmentSection.NotifyObservers(); + } } private static IEnumerable CreateControlItems( Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs =================================================================== diff -u -r0f68d5b3472a122ffda0030d2f78023ae34a6b6f -r4b557a57e20d32dc01a1bec3ed076ee85213b069 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 0f68d5b3472a122ffda0030d2f78023ae34a6b6f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 4b557a57e20d32dc01a1bec3ed076ee85213b069) @@ -199,41 +199,6 @@ } [Test] - public void WaveHeightLocationsView_AssessmentSectionUpdated_DataGridViewCorrectlyUpdated() - { - // Setup - WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(testForm); - IAssessmentSection assessmentSection = view.AssessmentSection; - - // Precondition - DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); - DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(5, rows.Count); - Assert.AreEqual("-", rows[0].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual(1.23.ToString(CultureInfo.CurrentCulture), rows[1].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[2].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[3].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual(1.01.ToString(CultureInfo.CurrentCulture), rows[4].Cells[locationWaveHeightColumnIndex].FormattedValue); - - assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.WaveHeightCalculation.Output = null); - - var refreshed = false; - dataGridView.Invalidated += (sender, args) => refreshed = true; - - // Call - assessmentSection.NotifyObservers(); - - // Assert - Assert.IsTrue(refreshed); - Assert.AreEqual(5, rows.Count); - Assert.AreEqual("-", rows[0].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[1].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[2].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[3].Cells[locationWaveHeightColumnIndex].FormattedValue); - Assert.AreEqual("-", rows[4].Cells[locationWaveHeightColumnIndex].FormattedValue); - } - - [Test] public void WaveHeightLocationsView_HydraulicBoundaryDatabaseUpdated_DataGridViewCorrectlyUpdated() { // Setup @@ -371,10 +336,26 @@ [TestFixture] public class DataSynchronisationTester : LocationsViewDataSynchronisationTester { - protected override void ShowFullyConfiguredLocationsView(Form form) + protected override int OutputColumnIndex { - ShowFullyConfiguredWaveHeightLocationsView(form); + get + { + return locationWaveHeightColumnIndex; + } } + + protected override LocationsView ShowFullyConfiguredLocationsView(Form form) + { + return ShowFullyConfiguredWaveHeightLocationsView(form); + } + + protected override void ClearLocationOutputAndNotifyObservers(LocationsView view) + { + IAssessmentSection assessmentSection = view.AssessmentSection; + + assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.WaveHeightCalculation.Output = null); + assessmentSection.NotifyObservers(); + } } private static IEnumerable CreateControlItems(