Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneLocationsView.cs =================================================================== diff -u -r714cfe37b354d87e8dee4a6d78de0a4c4615b6d6 -r3b8956569af566bb85af32fedceff955e064e9c3 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneLocationsView.cs (.../DuneLocationsView.cs) (revision 714cfe37b354d87e8dee4a6d78de0a4c4615b6d6) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneLocationsView.cs (.../DuneLocationsView.cs) (revision 3b8956569af566bb85af32fedceff955e064e9c3) @@ -21,10 +21,12 @@ using System.Collections.Generic; using System.Linq; +using Core.Common.Base; using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.Views; using Ringtoets.DuneErosion.Data; +using Ringtoets.DuneErosion.Forms.PresentationObjects; using Ringtoets.DuneErosion.Forms.Properties; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -88,7 +90,10 @@ protected override object CreateSelectedItemFromCurrentRow() { - return new object(); + var currentRow = dataGridViewControl.CurrentRow; + return currentRow != null + ? new DuneLocationContext((ObservableList) Data, ((DuneLocationRow) currentRow.DataBoundItem).DuneLocation) + : null; } protected override void SetDataSource() Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneLocationsViewTest.cs =================================================================== diff -u -rc824c971119bfdb785a6b1641a821fe344f22869 -r3b8956569af566bb85af32fedceff955e064e9c3 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneLocationsViewTest.cs (.../DuneLocationsViewTest.cs) (revision c824c971119bfdb785a6b1641a821fe344f22869) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneLocationsViewTest.cs (.../DuneLocationsViewTest.cs) (revision 3b8956569af566bb85af32fedceff955e064e9c3) @@ -29,6 +29,7 @@ using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Forms.Views; using Ringtoets.DuneErosion.Data; +using Ringtoets.DuneErosion.Forms.PresentationObjects; using Ringtoets.DuneErosion.Forms.Views; namespace Ringtoets.DuneErosion.Forms.Test.Views @@ -186,28 +187,38 @@ Assert.AreEqual(1.23.ToString(CultureInfo.CurrentCulture), cells[waterLevelColumnIndex].FormattedValue); Assert.AreEqual(2.34.ToString(CultureInfo.CurrentCulture), cells[waveHeightColumnIndex].FormattedValue); Assert.AreEqual(3.45.ToString(CultureInfo.CurrentCulture), cells[wavePeriodColumnIndex].FormattedValue); + } + [Test] + public void Selection_WithoutLocations_ReturnsNull() + { + // Call + using (var view = new DuneLocationsView()) + { + // Assert + Assert.IsNull(view.Selection); + } } - // [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); - // } - // } + [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 DuneLocationContext; + var dataBoundItem = selectedLocationRow.DataBoundItem as DuneLocationRow; + + Assert.NotNull(selection); + Assert.NotNull(dataBoundItem); + Assert.AreSame(dataBoundItem.DuneLocation, selection.DuneLocation); + } + } private DuneLocationsView ShowFullyConfiguredDuneLocationsView() {