Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/SelectableTopLevelIllustrationPoint.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/SelectableTopLevelIllustrationPoint.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/SelectableTopLevelIllustrationPoint.cs (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -0,0 +1,66 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Ringtoets.Common.Data.IllustrationPoints; + +namespace Ringtoets.Common.Forms.PresentationObjects +{ + /// + /// Class that represents a top level illustration point together + /// with all the calculated closing situations that are present. + /// + public class SelectableTopLevelIllustrationPoint + { + /// + /// Creates a new instance of . + /// + /// The . + /// The closing situations that are present. + /// Thrown when any parameter is null. + public SelectableTopLevelIllustrationPoint(TopLevelIllustrationPointBase topLevelIllustrationPoint, + IEnumerable closingSituations) + { + if (topLevelIllustrationPoint == null) + { + throw new ArgumentNullException(nameof(topLevelIllustrationPoint)); + } + if (closingSituations == null) + { + throw new ArgumentNullException(nameof(closingSituations)); + } + + TopLevelIllustrationPoint = topLevelIllustrationPoint; + ClosingSituations = closingSituations; + } + + /// + /// Gets the top level illustration point. + /// + public TopLevelIllustrationPointBase TopLevelIllustrationPoint { get; } + + /// + /// Gets the calculated closing situations. + /// + public IEnumerable ClosingSituations { get; } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/TopLevelSubMechanismIllustrationPointProperties.cs =================================================================== diff -u -r12b6d33eb444e7772320fc6f747e1b9ccf101002 -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/TopLevelSubMechanismIllustrationPointProperties.cs (.../TopLevelSubMechanismIllustrationPointProperties.cs) (revision 12b6d33eb444e7772320fc6f747e1b9ccf101002) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/TopLevelSubMechanismIllustrationPointProperties.cs (.../TopLevelSubMechanismIllustrationPointProperties.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Collections.Generic; using System.ComponentModel; using System.Linq; using Core.Common.Base.Data; @@ -39,6 +41,30 @@ [TypeConverter(typeof(ExpandableObjectConverter))] public class TopLevelSubMechanismIllustrationPointProperties : ObjectProperties { + private readonly IEnumerable closingSituations; + + /// + /// Creates a new instance of + /// + /// + /// The calculated closing situations. + /// Thrown when any parameter is + /// null. + public TopLevelSubMechanismIllustrationPointProperties(TopLevelSubMechanismIllustrationPoint data, + IEnumerable closingSituations) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + if (closingSituations == null) + { + throw new ArgumentNullException(nameof(closingSituations)); + } + Data = data; + this.closingSituations = closingSituations; + } + [PropertyOrder(1)] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.CalculationOutput_IllustrationPointName_DisplayName))] @@ -90,6 +116,7 @@ } [PropertyOrder(5)] + [DynamicVisible] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.IllustrationPoint_ClosingSituation_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.IllustrationPoint_ClosingSituation_Description))] @@ -143,9 +170,27 @@ } } + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + if (propertyName == nameof(ClosingSituation)) + { + return !AreClosingSituationsSame(); + } + + return false; + } + + private bool AreClosingSituationsSame() + { + return closingSituations.All(cs => cs == closingSituations.First()); + } + public override string ToString() { - return string.Format(Resources.TopLevelSubMechanismIllustrationPointProperties_ToString_WindDirectionName_0_ClosingSituation_1, + return AreClosingSituationsSame() + ? data.WindDirection.Name + : string.Format(Resources.TopLevelSubMechanismIllustrationPointProperties_ToString_WindDirectionName_0_ClosingSituation_1, data.WindDirection.Name, data.ClosingSituation); } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -r725c8f3f2d63b42aca7769e2195bb5b4fd0e938e -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 725c8f3f2d63b42aca7769e2195bb5b4fd0e938e) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -74,6 +74,7 @@ + True True Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsTableControl.cs =================================================================== diff -u -r725c8f3f2d63b42aca7769e2195bb5b4fd0e938e -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsTableControl.cs (.../IllustrationPointsTableControl.cs) (revision 725c8f3f2d63b42aca7769e2195bb5b4fd0e938e) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsTableControl.cs (.../IllustrationPointsTableControl.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -24,7 +24,9 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Controls.Views; +using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.Properties; namespace Ringtoets.Common.Forms.Views @@ -74,8 +76,7 @@ get { DataGridViewRow currentRow = illustrationPointsDataGridViewControl.CurrentRow; - - return ((IllustrationPointRow) currentRow?.DataBoundItem)?.IllustrationPointControlItem.Source; + return CreateSelectedItemFromCurrentRow(currentRow); } } @@ -85,6 +86,20 @@ InitializeDataGridView(); } + private object CreateSelectedItemFromCurrentRow(DataGridViewRow currentRow) + { + var illustrationPointRow = (IllustrationPointRow) currentRow?.DataBoundItem; + + SelectableTopLevelIllustrationPoint selection = null; + if (illustrationPointRow != null) + { + selection = new SelectableTopLevelIllustrationPoint( + (TopLevelIllustrationPointBase) illustrationPointRow.IllustrationPointControlItem.Source, + data.Select(ipc => ipc.ClosingSituation)); + } + return selection; + } + private void InitializeEventHandlers() { illustrationPointsDataGridViewControl.AddCurrentCellChangedHandler(DataGridViewOnCurrentCellChangedHandler); Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestTopLevelIllustrationPointTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestTopLevelIllustrationPointTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestTopLevelIllustrationPointTest.cs (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -0,0 +1,51 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using NUnit.Framework; +using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; + +namespace Ringtoets.Common.Data.TestUtil.Test.IllustrationPoints +{ + [TestFixture] + public class TestTopLevelIllustrationPointTest + { + [Test] + public void DefaultConstructor_ReturnsExpectedProperties() + { + // Call + var topLevelIllustrationPoint = new TestTopLevelIllustrationPoint(); + + // Assert + Assert.IsInstanceOf(topLevelIllustrationPoint); + Assert.AreEqual("Closing situation", topLevelIllustrationPoint.ClosingSituation); + + WindDirection expectedWindDirection = WindDirectionTestFactory.CreateTestWindDirection(); + AssertWindDirection(expectedWindDirection, topLevelIllustrationPoint.WindDirection); + } + + private static void AssertWindDirection(WindDirection expected, WindDirection actual) + { + Assert.AreEqual(expected.Name, actual.Name); + Assert.AreEqual(expected.Angle, actual.Angle); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj =================================================================== diff -u -r355b0e8dff79cfc8a42cf598f24a753ba5f57083 -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision 355b0e8dff79cfc8a42cf598f24a753ba5f57083) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -60,6 +60,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestTopLevelIllustrationPoint.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestTopLevelIllustrationPoint.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestTopLevelIllustrationPoint.cs (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -0,0 +1,39 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; + +namespace Ringtoets.Common.Data.TestUtil +{ + /// + /// A simple implementation of + /// which can be used for testing. + /// + public class TestTopLevelIllustrationPoint : TopLevelIllustrationPointBase + { + /// + /// Creates a new instance of . + /// + public TestTopLevelIllustrationPoint() + : base(WindDirectionTestFactory.CreateTestWindDirection(), "Closing situation") {} + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj =================================================================== diff -u -r355b0e8dff79cfc8a42cf598f24a753ba5f57083 -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision 355b0e8dff79cfc8a42cf598f24a753ba5f57083) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -82,6 +82,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/SelectableTopLevelIllustrationPointTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/SelectableTopLevelIllustrationPointTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/SelectableTopLevelIllustrationPointTest.cs (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -0,0 +1,74 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; + +namespace Ringtoets.Common.Forms.Test.PresentationObjects +{ + [TestFixture] + public class SelectableTopLevelIllustrationPointTest + { + [Test] + public void Constructor_TopLevelIllustrationPointNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SelectableTopLevelIllustrationPoint(null, + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("topLevelIllustrationPoint", exception.ParamName); + } + + [Test] + public void Constructor_ClosingSituationsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SelectableTopLevelIllustrationPoint(new TestTopLevelIllustrationPoint(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("closingSituations", exception.ParamName); + } + + [Test] + public void Constructor_ValidArguments_ReturnsExpectedValues() + { + // Setup + var topLevelIllustrationPoint = new TestTopLevelIllustrationPoint(); + IEnumerable closingSituations = Enumerable.Empty(); + + // Call + var illustrationPoint = new SelectableTopLevelIllustrationPoint(topLevelIllustrationPoint, + closingSituations); + + // Assert + Assert.AreSame(topLevelIllustrationPoint, illustrationPoint.TopLevelIllustrationPoint); + Assert.AreSame(closingSituations, illustrationPoint.ClosingSituations); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelSubMechanismIllustrationPointPropertiesTest.cs =================================================================== diff -u -r12b6d33eb444e7772320fc6f747e1b9ccf101002 -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelSubMechanismIllustrationPointPropertiesTest.cs (.../TopLevelSubMechanismIllustrationPointPropertiesTest.cs) (revision 12b6d33eb444e7772320fc6f747e1b9ccf101002) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelSubMechanismIllustrationPointPropertiesTest.cs (.../TopLevelSubMechanismIllustrationPointPropertiesTest.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.ComponentModel; using System.Linq; using Core.Common.Gui.Converters; @@ -39,23 +40,52 @@ private const int calculatedProbabilityPropertyIndex = 1; private const int calculatedReliabilityPropertyIndex = 2; private const int windDirectionNamePropertyIndex = 3; - private const int closingSituationPropertyIndex = 4; - private const int alphaValuesPropertyIndex = 5; - private const int durationPropertyIndex = 6; - private const int illustrationPointResultsPropertyIndex = 7; + private const int alphaValuesPropertyIndex = 4; + private const int durationPropertyIndex = 5; + private const int illustrationPointResultsPropertyIndex = 6; [Test] + public void Constructor_DataNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new TopLevelSubMechanismIllustrationPointProperties(null, Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("data", exception.ParamName); + } + + [Test] + public void Constructor_ClosingSituationsNull_ThrowsArgumentNullException() + { + // Setup + var data = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), + string.Empty, + new TestSubMechanismIllustrationPoint()); + + // Call + TestDelegate call = () => new TopLevelSubMechanismIllustrationPointProperties(data, null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("closingSituations", exception.ParamName); + } + + [Test] public void Constructor_DefaultArgumentValues_DoesNotThrowException() { // Call - var properties = new TopLevelSubMechanismIllustrationPointProperties(); + var properties = new TopLevelSubMechanismIllustrationPointProperties( + new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), + string.Empty, + new TestSubMechanismIllustrationPoint()), Enumerable.Empty()); // Assert Assert.IsInstanceOf>(properties); } [Test] - public void ToString_Always_ReturnsCombinationOfWindDirectionAndClosingSituation() + public void ToString_DifferentClosingSituations_ReturnsCombinationOfWindDirectionAndClosingSituation() { // Setup string illustrationPointName = string.Empty; @@ -72,17 +102,81 @@ submechanismIllustrationPoint); // Call - var hydraulicBoundaryLocationProperties = new TopLevelSubMechanismIllustrationPointProperties - { - Data = context - }; + var properties = new TopLevelSubMechanismIllustrationPointProperties( + context, + new[] + { + closingSituation, + "Different situation" + }); // Assert string expectedStringValue = $"{windDirection.Name} ({closingSituation})"; - Assert.AreEqual(expectedStringValue, hydraulicBoundaryLocationProperties.ToString()); + Assert.AreEqual(expectedStringValue, properties.ToString()); } [Test] + public void ToString_SameClosingSituations_ReturnsWindDirectionName() + { + // Setup + string illustrationPointName = string.Empty; + var submechanismIllustrationPoint = + new SubMechanismIllustrationPoint(illustrationPointName, + 3, + Enumerable.Empty(), + Enumerable.Empty()); + + const string closingSituation = "direction"; + WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); + var context = new TopLevelSubMechanismIllustrationPoint(windDirection, + closingSituation, + submechanismIllustrationPoint); + + // Call + var properties = new TopLevelSubMechanismIllustrationPointProperties( + context, + Enumerable.Empty()); + + // Assert + string expectedStringValue = $"{windDirection.Name}"; + Assert.AreEqual(expectedStringValue, properties.ToString()); + } + + [Test] + public void GetProperties_DifferentClosingSituations_ReturnsExpectedAttributeValues() + { + // Setup + var submechanismIllustrationPoint = + new SubMechanismIllustrationPoint(string.Empty, + 3, + Enumerable.Empty(), + Enumerable.Empty()); + + const string closingSituation = "Closing Situation"; + WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); + var data = new TopLevelSubMechanismIllustrationPoint(windDirection, + closingSituation, + submechanismIllustrationPoint); + + // Call + var properties = new TopLevelSubMechanismIllustrationPointProperties(data, new[] + { + closingSituation, + "Different closing situation" + }); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(8, dynamicProperties.Count); + + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[4], + "Algemeen", + "Sluitscenario", + "Het sluitscenario waarvoor dit illustratiepunt is berekend.", + true); + } + + [Test] public void GetProperties_ValidData_ReturnsExpectedValues() { // Setup @@ -110,10 +204,7 @@ var context = new TopLevelSubMechanismIllustrationPoint(windDirection, closingSituation, submechanismIllustrationPoint); // Call - var properties = new TopLevelSubMechanismIllustrationPointProperties - { - Data = context - }; + var properties = new TopLevelSubMechanismIllustrationPointProperties(context, Enumerable.Empty()); // Assert Assert.AreEqual(illustrationPointName, properties.Name); @@ -127,7 +218,7 @@ Assert.IsInstanceOf(classTypeConverter); PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(8, dynamicProperties.Count); + Assert.AreEqual(7, dynamicProperties.Count); const string generalCategory = "Algemeen"; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[namePropertyIndex], @@ -154,12 +245,6 @@ "De windrichting waarvoor dit illlustratiepunt is berekend.", true); - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[closingSituationPropertyIndex], - generalCategory, - "Sluitscenario", - "Het sluitscenario waarvoor dit illustratiepunt is berekend.", - true); - TestHelper.AssertTypeConverter(nameof(TopLevelSubMechanismIllustrationPointProperties.AlphaValues)); PropertyDescriptor alphaValuesProperty = dynamicProperties[alphaValuesPropertyIndex]; Assert.NotNull(alphaValuesProperty.Attributes[typeof(KeyValueElementAttribute)]); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -r725c8f3f2d63b42aca7769e2195bb5b4fd0e938e -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 725c8f3f2d63b42aca7769e2195bb5b4fd0e938e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -86,6 +86,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs =================================================================== diff -u -rfee74e8fb98844af091f9b061d9470540dfdd6f0 -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs (.../IllustrationPointsControlTest.cs) (revision fee74e8fb98844af091f9b061d9470540dfdd6f0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs (.../IllustrationPointsControlTest.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -28,6 +28,8 @@ using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Common.Forms.Views; @@ -129,7 +131,7 @@ control.Data = new[] { - new IllustrationPointControlItem(new object(), + new IllustrationPointControlItem(new TestTopLevelIllustrationPoint(), "SSE", "Regular", Enumerable.Empty(), @@ -145,7 +147,13 @@ object selection = tableControl.Selection; // Assert - Assert.AreSame(selection, control.Selection); + var expectedSelection = selection as SelectableTopLevelIllustrationPoint; + var controlSelection = control.Selection as SelectableTopLevelIllustrationPoint; + Assert.IsNotNull(expectedSelection); + Assert.IsNotNull(controlSelection); + + Assert.AreSame(expectedSelection.TopLevelIllustrationPoint, controlSelection.TopLevelIllustrationPoint); + CollectionAssert.AreEqual(expectedSelection.ClosingSituations, controlSelection.ClosingSituations); } } } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsTableControlTest.cs =================================================================== diff -u -rfee74e8fb98844af091f9b061d9470540dfdd6f0 -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsTableControlTest.cs (.../IllustrationPointsTableControlTest.cs) (revision fee74e8fb98844af091f9b061d9470540dfdd6f0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsTableControlTest.cs (.../IllustrationPointsTableControlTest.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -28,6 +28,8 @@ using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Common.Forms.Views; @@ -242,12 +244,15 @@ selectedLocationRow.Cells[0].Value = true; // Assert - object selection = control.Selection; + var selection = control.Selection as SelectableTopLevelIllustrationPoint; var dataBoundItem = selectedLocationRow.DataBoundItem as IllustrationPointRow; Assert.NotNull(selection); Assert.NotNull(dataBoundItem); - Assert.AreSame(dataBoundItem.IllustrationPointControlItem.Source, selection); + Assert.AreSame(dataBoundItem.IllustrationPointControlItem.Source, selection.TopLevelIllustrationPoint); + + string[] expectedClosingSituations = control.Data.Select(ipc => ipc.ClosingSituation).ToArray(); + CollectionAssert.AreEqual(expectedClosingSituations, selection.ClosingSituations); } private IllustrationPointsTableControl ShowControl() @@ -264,12 +269,12 @@ { return new[] { - new IllustrationPointControlItem(new object(), + new IllustrationPointControlItem(new TestTopLevelIllustrationPoint(), "SSE", "Regular", Enumerable.Empty(), new RoundedDouble(5, 0.9)), - new IllustrationPointControlItem(new object(), + new IllustrationPointControlItem(new TestTopLevelIllustrationPoint(), "SSE", "Open", Enumerable.Empty(), Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/LocationsViewTest.cs =================================================================== diff -u -r2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8 -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/LocationsViewTest.cs (.../LocationsViewTest.cs) (revision 2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/LocationsViewTest.cs (.../LocationsViewTest.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -30,6 +30,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; +using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Common.Forms.Views; @@ -188,7 +189,10 @@ object selection = view.Selection; // Then - Assert.AreSame(calculatableObject.GeneralResult.TopLevelIllustrationPoints.ElementAt(1), selection); + var selectableTopLevelIllustrationPoint = selection as SelectableTopLevelIllustrationPoint; + Assert.IsNotNull(selectableTopLevelIllustrationPoint); + Assert.AreSame(calculatableObject.GeneralResult.TopLevelIllustrationPoints.ElementAt(1), + selectableTopLevelIllustrationPoint.TopLevelIllustrationPoint); } [Test] Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsHydraulicBoundaryLocationContextProperties.cs =================================================================== diff -u -r2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8 -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsHydraulicBoundaryLocationContextProperties.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationContextProperties.cs) (revision 2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsHydraulicBoundaryLocationContextProperties.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationContextProperties.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -161,13 +161,14 @@ { get { - return GetGeneralResultSubMechanismIllustrationPoints() - .TopLevelIllustrationPoints - .Select(p => new TopLevelSubMechanismIllustrationPointProperties - { - Data = p - }) - .ToArray(); + IEnumerable topLevelIllustrationPoints = + GetGeneralResultSubMechanismIllustrationPoints().TopLevelIllustrationPoints; + + IEnumerable closingSituations = topLevelIllustrationPoints.Select(s => s.ClosingSituation) + .ToArray(); + + return topLevelIllustrationPoints.Select(p => new TopLevelSubMechanismIllustrationPointProperties(p, closingSituations)) + .ToArray(); } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs =================================================================== diff -u -r2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8 -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs (.../HydraulicBoundaryLocationProperties.cs) (revision 2e5f2b59e81cda48f3d7ee03afa4db88abc7b1a8) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs (.../HydraulicBoundaryLocationProperties.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -196,13 +196,14 @@ { get { - return GetGeneralResultSubMechanismIllustrationPoints() - .TopLevelIllustrationPoints - .Select(p => new TopLevelSubMechanismIllustrationPointProperties - { - Data = p - }) - .ToArray(); + IEnumerable topLevelIllustrationPoints = + GetGeneralResultSubMechanismIllustrationPoints().TopLevelIllustrationPoints; + + IEnumerable closingSituations = topLevelIllustrationPoints.Select(s => s.ClosingSituation) + .ToArray(); + + return topLevelIllustrationPoints.Select(p => new TopLevelSubMechanismIllustrationPointProperties(p, closingSituations)) + .ToArray(); } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r357925a9ba2aebce58a9e03e620c6d470323672f -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 357925a9ba2aebce58a9e03e620c6d470323672f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -321,7 +321,19 @@ { CreateInstance = context => new ForeshoreProfileCollectionProperties(context.WrappedData) }; - yield return new PropertyInfo(); + yield return new PropertyInfo + { + CreateInstance = illustrationPoint => + { + var topLevelIllustrationPoint = illustrationPoint.TopLevelIllustrationPoint as TopLevelSubMechanismIllustrationPoint; + if (topLevelIllustrationPoint != null) + { + return new TopLevelSubMechanismIllustrationPointProperties(topLevelIllustrationPoint, + illustrationPoint.ClosingSituations); + } + return null; + } + }; } /// Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -r23c107445180b538c4716f96c9067fe6d29f11aa -rf355d0e0bb55d60f34ae6be35e667cbb03dc8c20 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 23c107445180b538c4716f96c9067fe6d29f11aa) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision f355d0e0bb55d60f34ae6be35e667cbb03dc8c20) @@ -280,7 +280,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(TopLevelSubMechanismIllustrationPoint), + typeof(SelectableTopLevelIllustrationPoint), typeof(TopLevelSubMechanismIllustrationPointProperties)); PluginTestHelper.AssertPropertyInfoDefined(