Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -ra3273b4a5d21f952ab7dabfd2120f8c8632e0519 -r13d9407c89466e20fe912bb64d078358f8d03afc --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision a3273b4a5d21f952ab7dabfd2120f8c8632e0519) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 13d9407c89466e20fe912bb64d078358f8d03afc) @@ -25,12 +25,14 @@ using System.Windows.Forms; using Core.Common.Base; using Core.Common.Base.Geometry; +using Core.Common.Controls.DataGrid; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; using Ringtoets.Common.Forms.GuiServices; using Ringtoets.Common.Forms.Views; using Ringtoets.Common.Service.MessageProviders; @@ -90,23 +92,69 @@ public void Selection_WithLocations_ReturnsSelectedLocationWrappedInContext() { // Call - using (DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView()) - { - var dataGridView = (DataGridView) testForm.Controls.Find("dataGridView", true).First(); - DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; - selectedLocationRow.Cells[0].Value = true; + DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); + var dataGridView = (DataGridView) testForm.Controls.Find("dataGridView", true).First(); + DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; + selectedLocationRow.Cells[0].Value = true; - // Assert - var selection = view.Selection as DesignWaterLevelLocationContext; - var dataBoundItem = selectedLocationRow.DataBoundItem as HydraulicBoundaryLocationRow; + // 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); - } + Assert.NotNull(selection); + Assert.NotNull(dataBoundItem); + Assert.AreSame(dataBoundItem.CalculatableObject, selection.HydraulicBoundaryLocation); } [Test] + public void Selection_LocationWithoutOutput_ChartControlDataSetToNull() + { + // Setup + ShowFullyConfiguredDesignWaterLevelLocationsView(); + var chartControl = (IllustrationPointsChartControl) testForm.Controls.Find("IllustrationPointsChartControl", true).Single(); + + var dataGridView = (DataGridViewControl) testForm.Controls.Find("dataGridViewControl", true).First(); + + // Call + dataGridView.SetCurrentCell(dataGridView.GetCell(0, 1)); + + // Assert + Assert.IsNull(chartControl.Data); + } + + [Test] + public void Selection_LocationWithoutGeneralResult_ChartControlDataSetToNull() + { + // Setup + ShowFullyConfiguredDesignWaterLevelLocationsView(); + var chartControl = (IllustrationPointsChartControl) testForm.Controls.Find("IllustrationPointsChartControl", true).Single(); + + var dataGridView = (DataGridViewControl) testForm.Controls.Find("dataGridViewControl", true).First(); + + // Call + dataGridView.SetCurrentCell(dataGridView.GetCell(1, 0)); + + // Assert + Assert.IsNull(chartControl.Data); + } + + [Test] + public void Selection_LocationWithGeneralResult_GeneralResultSetOnChartData() + { + // Setup + ShowFullyConfiguredDesignWaterLevelLocationsView(); + var chartControl = (IllustrationPointsChartControl) testForm.Controls.Find("IllustrationPointsChartControl", true).Single(); + + var dataGridView = (DataGridViewControl)testForm.Controls.Find("dataGridViewControl", true).First(); + + // Call + dataGridView.SetCurrentCell(dataGridView.GetCell(4, 0)); + + // Assert + Assert.IsNotNull(chartControl.Data); + } + + [Test] public void Constructor_DataGridViewCorrectlyInitialized() { // Setup & Call @@ -147,7 +195,7 @@ // Assert var dataGridView = (DataGridView) testForm.Controls.Find("dataGridView", true).First(); DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(4, rows.Count); + Assert.AreEqual(5, rows.Count); DataGridViewCellCollection cells = rows[0].Cells; Assert.AreEqual(6, cells.Count); @@ -184,6 +232,15 @@ Assert.AreEqual("4", cells[locationIdColumnIndex].FormattedValue); Assert.AreEqual(new Point2D(4, 4).ToString(), cells[locationColumnIndex].FormattedValue); Assert.AreEqual("-", cells[locationDesignWaterlevelColumnIndex].FormattedValue); + + cells = rows[4].Cells; + Assert.AreEqual(6, cells.Count); + Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual(true, cells[includeIllustrationPointsColumnIndex].FormattedValue); + Assert.AreEqual("5", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("5", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(5, 5).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual(1.01.ToString(CultureInfo.CurrentCulture), cells[locationDesignWaterlevelColumnIndex].FormattedValue); } [Test] @@ -209,7 +266,7 @@ // Precondition var dataGridView = (DataGridView) testForm.Controls.Find("dataGridView", true).First(); DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(4, rows.Count); + Assert.AreEqual(5, rows.Count); assessmentSection.HydraulicBoundaryDatabase = newHydraulicBoundaryDatabase; @@ -238,22 +295,24 @@ // Precondition var dataGridView = (DataGridView) testForm.Controls.Find("dataGridView", true).First(); DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(4, rows.Count); + 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); // Call assessmentSection.HydraulicBoundaryDatabase.Locations.ForEach(loc => loc.DesignWaterLevelCalculation.Output = null); assessmentSection.NotifyObservers(); // Assert - Assert.AreEqual(4, rows.Count); + 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] @@ -377,6 +436,19 @@ } } }); + var output = new TestHydraulicBoundaryLocationOutput(1.01); + output.SetIllustrationPoints(new TestGeneralResult()); + Locations.Add(new HydraulicBoundaryLocation(5, "5", 5.0, 5.0) + { + DesignWaterLevelCalculation = + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + }, + Output = output + } + }); } } }