Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneLocationRow.cs =================================================================== diff -u -r34d0075af5464460642aeb1c0e412f2543663a4a -r714cfe37b354d87e8dee4a6d78de0a4c4615b6d6 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneLocationRow.cs (.../DuneLocationRow.cs) (revision 34d0075af5464460642aeb1c0e412f2543663a4a) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneLocationRow.cs (.../DuneLocationRow.cs) (revision 714cfe37b354d87e8dee4a6d78de0a4c4615b6d6) @@ -20,10 +20,14 @@ // All rights reserved. using System; +using System.ComponentModel; +using System.Globalization; using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; using Ringtoets.DuneErosion.Data; +using DuneErosionDataResources = Ringtoets.DuneErosion.Data.Properties.Resources; namespace Ringtoets.DuneErosion.Forms.Views { @@ -99,17 +103,18 @@ /// /// Gets the . /// - public RoundedDouble Offset + public string Offset { get { - return DuneLocation.Offset; + return DuneLocation.Offset.ToString(DuneErosionDataResources.DuneLocation_Offset_format, CultureInfo.InvariantCulture); } } /// /// Gets the . /// + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] public RoundedDouble WaterLevel { get @@ -121,6 +126,7 @@ /// /// Gets the . /// + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] public RoundedDouble WaveHeight { get @@ -132,6 +138,7 @@ /// /// Gets the . /// + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] public RoundedDouble WavePeriod { get Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneLocationsView.cs =================================================================== diff -u -r5aee7500a79df405af054d508f4d4d71c0437c36 -r714cfe37b354d87e8dee4a6d78de0a4c4615b6d6 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneLocationsView.cs (.../DuneLocationsView.cs) (revision 5aee7500a79df405af054d508f4d4d71c0437c36) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneLocationsView.cs (.../DuneLocationsView.cs) (revision 714cfe37b354d87e8dee4a6d78de0a4c4615b6d6) @@ -20,6 +20,7 @@ // All rights reserved. using System.Collections.Generic; +using System.Linq; using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.Views; @@ -90,7 +91,10 @@ return new object(); } - protected override void SetDataSource() {} + protected override void SetDataSource() + { + dataGridViewControl.SetDataSource(locations?.Select(l => new DuneLocationRow(l)).ToArray()); + } protected override void CalculateForSelectedRows() {} } Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneLocationRowTest.cs =================================================================== diff -u -r34d0075af5464460642aeb1c0e412f2543663a4a -r714cfe37b354d87e8dee4a6d78de0a4c4615b6d6 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneLocationRowTest.cs (.../DuneLocationRowTest.cs) (revision 34d0075af5464460642aeb1c0e412f2543663a4a) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneLocationRowTest.cs (.../DuneLocationRowTest.cs) (revision 714cfe37b354d87e8dee4a6d78de0a4c4615b6d6) @@ -21,8 +21,10 @@ using System; using Core.Common.Base.Geometry; +using Core.Common.Utils.Reflection; using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; using Ringtoets.DuneErosion.Data; using Ringtoets.DuneErosion.Forms.Views; @@ -44,13 +46,15 @@ } [Test] - public void Constructor_WithOutput_ExpectedValues() + [TestCase(34.1, "34.1")] + [TestCase(34.0, "34")] + public void Constructor_WithOutput_ExpectedValues(double offSet, string expectedRowOffset) { // Setup var location = new DuneLocation(1, "test location", new Point2D(3.3, 4.4), new DuneLocation.ConstructionProperties { CoastalAreaId = 2, - Offset = 34.1, + Offset = offSet, D50 = 0.000183 }) { @@ -72,11 +76,18 @@ Assert.AreEqual(location.Name, row.Name); Assert.AreSame(location.Location, row.Location); Assert.AreEqual(location.CoastalAreaId, row.CoastalAreaId); - Assert.AreEqual(location.Offset, row.Offset); + Assert.AreEqual(expectedRowOffset, row.Offset); Assert.AreEqual(location.D50, row.D50); Assert.AreEqual(location.Output.WaterLevel, row.WaterLevel); Assert.AreEqual(location.Output.WaveHeight, row.WaveHeight); Assert.AreEqual(location.Output.WavePeriod, row.WavePeriod); + + Assert.IsTrue(TypeUtils.HasTypeConverter(r => r.WaterLevel)); + Assert.IsTrue(TypeUtils.HasTypeConverter(r => r.WaveHeight)); + Assert.IsTrue(TypeUtils.HasTypeConverter(r => r.WavePeriod)); } [Test] @@ -100,7 +111,7 @@ Assert.AreEqual(location.Name, row.Name); Assert.AreSame(location.Location, row.Location); Assert.AreEqual(location.CoastalAreaId, row.CoastalAreaId); - Assert.AreEqual(location.Offset, row.Offset); + Assert.AreEqual(location.Offset.ToString(), row.Offset); Assert.AreEqual(location.D50, row.D50); Assert.IsNaN(row.WaterLevel); Assert.IsNaN(row.WaveHeight); Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneLocationsViewTest.cs =================================================================== diff -u -r5aee7500a79df405af054d508f4d4d71c0437c36 -r714cfe37b354d87e8dee4a6d78de0a4c4615b6d6 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneLocationsViewTest.cs (.../DuneLocationsViewTest.cs) (revision 5aee7500a79df405af054d508f4d4d71c0437c36) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneLocationsViewTest.cs (.../DuneLocationsViewTest.cs) (revision 714cfe37b354d87e8dee4a6d78de0a4c4615b6d6) @@ -19,10 +19,14 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Globalization; using System.Linq; using System.Windows.Forms; +using Core.Common.Base; +using Core.Common.Base.Geometry; using NUnit.Extensions.Forms; using NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Forms.Views; using Ringtoets.DuneErosion.Data; using Ringtoets.DuneErosion.Forms.Views; @@ -37,7 +41,7 @@ private const int locationIdColumnIndex = 2; private const int locationColumnIndex = 3; private const int coastalAreaIdColumnIndex = 4; - private const int offssetColumnIndex = 5; + private const int offsetColumnIndex = 5; private const int waterLevelColumnIndex = 6; private const int waveHeightColumnIndex = 7; private const int wavePeriodColumnIndex = 8; @@ -94,7 +98,7 @@ var coastalAreaIdColumn = (DataGridViewTextBoxColumn)dataGridView.Columns[coastalAreaIdColumnIndex]; Assert.AreEqual("Kustvaknummer", coastalAreaIdColumn.HeaderText); - var offssetColumn = (DataGridViewTextBoxColumn)dataGridView.Columns[offssetColumnIndex]; + var offssetColumn = (DataGridViewTextBoxColumn)dataGridView.Columns[offsetColumnIndex]; Assert.AreEqual("Metrering [dam]", offssetColumn.HeaderText); var waterLevelColumn = (DataGridViewTextBoxColumn)dataGridView.Columns[waterLevelColumnIndex]; @@ -146,6 +150,95 @@ } } + [Test] + public void DesignWaterLevelLocationsView_AssessmentSectionWithData_DataGridViewCorrectlyInitialized() + { + // Setup & Call + ShowFullyConfiguredDuneLocationsView(); + + // Assert + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + var rows = dataGridView.Rows; + Assert.AreEqual(2, rows.Count); + + var cells = rows[0].Cells; + Assert.AreEqual(10, cells.Count); + Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual("1", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("1", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(1, 1).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual("50", cells[coastalAreaIdColumnIndex].FormattedValue); + Assert.AreEqual("320", cells[offsetColumnIndex].FormattedValue); + Assert.AreEqual("0.000837", cells[d50ColumnIndex].FormattedValue); + Assert.AreEqual("-", cells[waterLevelColumnIndex].FormattedValue); + Assert.AreEqual("-", cells[waveHeightColumnIndex].FormattedValue); + Assert.AreEqual("-", cells[wavePeriodColumnIndex].FormattedValue); + + cells = rows[1].Cells; + Assert.AreEqual(10, cells.Count); + Assert.AreEqual(false, cells[locationCalculateColumnIndex].FormattedValue); + Assert.AreEqual("2", cells[locationNameColumnIndex].FormattedValue); + Assert.AreEqual("2", cells[locationIdColumnIndex].FormattedValue); + Assert.AreEqual(new Point2D(2, 2).ToString(), cells[locationColumnIndex].FormattedValue); + Assert.AreEqual("60", cells[coastalAreaIdColumnIndex].FormattedValue); + Assert.AreEqual("230", cells[offsetColumnIndex].FormattedValue); + Assert.AreEqual("0.000123", cells[d50ColumnIndex].FormattedValue); + Assert.AreEqual("1.00", cells[waterLevelColumnIndex].FormattedValue); + Assert.AreEqual("2.00", cells[waveHeightColumnIndex].FormattedValue); + Assert.AreEqual("3.00", cells[wavePeriodColumnIndex].FormattedValue); + + } + + // [Test] + // public void Selection_WithLocations_ReturnsSelectedLocationWrappedInContext() + // { + // // Call + // using (var view = ShowFullyConfiguredDuneLocationsView()) + // { + // var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + // var selectedLocationRow = dataGridView.Rows[0]; + // selectedLocationRow.Cells[0].Value = true; + // + // // Assert + // var selection = view.Selection as GrassCoverErosionOutwardsDesignWaterLevelLocationContext; + // var dataBoundItem = selectedLocationRow.DataBoundItem as DuneLocationRow; + // + // Assert.NotNull(selection); + // Assert.NotNull(dataBoundItem); + // Assert.AreSame(dataBoundItem.DuneLocation, selection.DuneLocation); + // } + // } + + private DuneLocationsView ShowFullyConfiguredDuneLocationsView() + { + var view = ShowDuneLocationsView(); + view.Data = new ObservableList + { + new DuneLocation(1, "1", new Point2D(1.0, 1.0), new DuneLocation.ConstructionProperties + { + CoastalAreaId = 50, + Offset = 320, + D50 = 0.000837 + }), + new DuneLocation(2, "2", new Point2D(2.0, 2.0), new DuneLocation.ConstructionProperties + { + CoastalAreaId = 60, + Offset = 230, + D50 = 0.000123 + }) + { + Output = new DuneLocationOutput(CalculationConvergence.CalculatedConverged, new DuneLocationOutput.ConstructionProperties + { + WaterLevel = 1.0, + WaveHeight = 2.0, + WavePeriod = 3.0 + }) + } + }; + + return view; + } + private DuneLocationsView ShowDuneLocationsView() { var view = new DuneLocationsView();