Index: Core/Common/src/Core.Common.Gui/UITypeEditors/SelectionEditor.cs =================================================================== diff -u -r36ae24e23e98decab1477c1be19b96cdf490a917 -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Core/Common/src/Core.Common.Gui/UITypeEditors/SelectionEditor.cs (.../SelectionEditor.cs) (revision 36ae24e23e98decab1477c1be19b96cdf490a917) +++ Core/Common/src/Core.Common.Gui/UITypeEditors/SelectionEditor.cs (.../SelectionEditor.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -74,7 +74,8 @@ /// /// This class provides a base implementation of and defines a drop down list - /// edit-control used for calculation input data. + /// edit-control used for calculation input data. Allows the user to populate the list with internal presentation types and + /// convert them to domain types. /// /// The type of items that populate the list-edit control. /// The type of item the list should return once selected. Index: Core/Common/test/Core.Common.Gui.Test/UITypeEditors/SelectionEditorTest.cs =================================================================== diff -u -r36ae24e23e98decab1477c1be19b96cdf490a917 -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Core/Common/test/Core.Common.Gui.Test/UITypeEditors/SelectionEditorTest.cs (.../SelectionEditorTest.cs) (revision 36ae24e23e98decab1477c1be19b96cdf490a917) +++ Core/Common/test/Core.Common.Gui.Test/UITypeEditors/SelectionEditorTest.cs (.../SelectionEditorTest.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -37,34 +37,62 @@ public void GetEditStyle_Always_ReturnDropDown() { // Setup - var editor = new SelectionEditor(); + var editorNoDomainType = new SelectionEditor(); + var editorWithDomainType = new SelectionEditor(); // Call - var editStyle = editor.GetEditStyle(); + var editStyleNoDomainType = editorNoDomainType.GetEditStyle(); + var editStyleWithDomainType = editorWithDomainType.GetEditStyle(); // Assert - Assert.AreEqual(UITypeEditorEditStyle.DropDown, editStyle); + Assert.AreEqual(UITypeEditorEditStyle.DropDown, editStyleNoDomainType); + Assert.AreEqual(UITypeEditorEditStyle.DropDown, editStyleWithDomainType); } [Test] public void EditValue_NoProviderNoContext_ReturnsOriginalValue() { // Setup + var editorNoDomainType = new SelectionEditor(); + var editorWithDomainType = new SelectionEditor(); + var someValue = new object(); + + // Call + var editStyleNoDomainType = editorNoDomainType.EditValue(null, null, someValue); + var editStyleWithDomainType = editorWithDomainType.EditValue(null, null, someValue); + + // Assert + Assert.AreSame(someValue, editStyleNoDomainType); + Assert.AreSame(someValue, editStyleWithDomainType); + } + + [Test] + public void EditValue_NoContextAndNoDomainType_ReturnsOriginalValue() + { + // Setup var editor = new SelectionEditor(); + var mockRepository = new MockRepository(); + var provider = mockRepository.StrictMock(); + var service = mockRepository.StrictMock(); + provider.Expect(p => p.GetService(null)).IgnoreArguments().Return(service); + mockRepository.ReplayAll(); + var someValue = new object(); // Call - var result = editor.EditValue(null, null, someValue); + var result = editor.EditValue(null, provider, someValue); // Assert Assert.AreSame(someValue, result); + + mockRepository.VerifyAll(); } [Test] - public void EditValue_NoContext_ReturnsOriginalValue() + public void EditValue_NoContextAndWithDomainType_ReturnsOriginalValue() { // Setup - var editor = new SelectionEditor(); + var editor = new SelectionEditor(); var mockRepository = new MockRepository(); var provider = mockRepository.StrictMock(); var service = mockRepository.StrictMock(); @@ -83,7 +111,7 @@ } [Test] - public void EditValue_Always_ReturnsOriginalValue() + public void EditValue_NoDomainTypeAlways_ReturnsOriginalValue() { // Setup var editor = new SelectionEditor(); @@ -107,6 +135,31 @@ } [Test] + public void EditValue_WithDomainTypeAlways_ReturnsOriginalValueInDomainType() + { + // Setup + var editor = new SelectionEditor(); + var mockRepository = new MockRepository(); + var provider = mockRepository.StrictMock(); + var service = mockRepository.StrictMock(); + var context = mockRepository.StrictMock(); + provider.Expect(p => p.GetService(null)).IgnoreArguments().Return(service); + service.Expect(s => s.DropDownControl(null)).IgnoreArguments(); + mockRepository.ReplayAll(); + + var someValue = new TestClass(); + + // Call + var result = editor.EditValue(context, provider, someValue); + + // Assert + Assert.AreSame(someValue, result); + Assert.IsTrue(result.GetType() == typeof(TestClass)); + + mockRepository.VerifyAll(); + } + + [Test] public void EditValue_NullItem_ReturnsNull() { var nullItem = new object(); @@ -129,12 +182,14 @@ mockRepository.VerifyAll(); } - private class TestSelectionEditor : SelectionEditor + private class TestSelectionEditor : SelectionEditor { public TestSelectionEditor(object nullItem) { NullItem = nullItem; } } + + private class TestClass {} } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -23,7 +23,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; -using System.Linq; using System.Linq.Expressions; using Core.Common.Base; using Core.Common.Base.Data; @@ -41,6 +40,7 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.Properties; using Ringtoets.Common.Forms.UITypeEditors; +using Ringtoets.HydraRing.Data; namespace Ringtoets.Common.Forms.PropertyClasses { @@ -157,14 +157,16 @@ public abstract IEnumerable GetAvailableForeshoreProfiles(); - public IEnumerable GetSelectableHydraulicBoundaryLocations() + public Point2D GetReferenceLocation() { - return data.AvailableHydraulicBoundaryLocations - .Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, StructureLocation)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); + return StructureLocation; } + public IEnumerable GetHydraulicBoundaryLocations() + { + return data.AvailableHydraulicBoundaryLocations; + } + public abstract IEnumerable GetAvailableStructures(); /// @@ -508,17 +510,15 @@ [ResourcesCategory(typeof(Resources), "Categories_HydraulicData")] [ResourcesDisplayName(typeof(Resources), "HydraulicBoundaryLocation_DisplayName")] [ResourcesDescription(typeof(Resources), "HydraulicBoundaryLocation_Description")] - public SelectableHydraulicBoundaryLocation SelectedHydraulicBoundaryLocation + public HydraulicBoundaryLocation SelectedHydraulicBoundaryLocation { get { - return data.WrappedData.HydraulicBoundaryLocation != null - ? new SelectableHydraulicBoundaryLocation(data.WrappedData.HydraulicBoundaryLocation, StructureLocation) - : null; + return data.WrappedData.HydraulicBoundaryLocation; } set { - data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation; + data.WrappedData.HydraulicBoundaryLocation = value; data.WrappedData.NotifyObservers(); } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/UITypeEditors/HydraulicBoundaryLocationEditor.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Common/src/Ringtoets.Common.Forms/UITypeEditors/HydraulicBoundaryLocationEditor.cs (.../HydraulicBoundaryLocationEditor.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/UITypeEditors/HydraulicBoundaryLocationEditor.cs (.../HydraulicBoundaryLocationEditor.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -21,7 +21,10 @@ using System.Collections.Generic; using System.ComponentModel; +using System.Linq; +using Core.Common.Base.Geometry; using Core.Common.Gui.UITypeEditors; +using Ringtoets.HydraRing.Data; namespace Ringtoets.Common.Forms.UITypeEditors { @@ -30,16 +33,30 @@ /// hydraulic boundary location from a collection. /// public class HydraulicBoundaryLocationEditor : SelectionEditor + HydraulicBoundaryLocation, SelectableHydraulicBoundaryLocation> { protected override IEnumerable GetAvailableOptions(ITypeDescriptorContext context) { - return GetPropertiesObject(context).GetSelectableHydraulicBoundaryLocations(); + IEnumerable hydraulicBoundaryLocations = + GetPropertiesObject(context).GetHydraulicBoundaryLocations(); + Point2D referencePoint = GetPropertiesObject(context).GetReferenceLocation(); + + return hydraulicBoundaryLocations.Select(hbl => + new SelectableHydraulicBoundaryLocation(hbl, referencePoint)) + .OrderBy(hbl => hbl.Distance.Value) + .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); } protected override SelectableHydraulicBoundaryLocation GetCurrentOption(ITypeDescriptorContext context) { - return GetPropertiesObject(context).SelectedHydraulicBoundaryLocation; + return new SelectableHydraulicBoundaryLocation(GetPropertiesObject(context).SelectedHydraulicBoundaryLocation, + GetPropertiesObject(context).GetReferenceLocation()); } + + protected override HydraulicBoundaryLocation ConvertToDomainType(object selectedItem) + { + var selected = (SelectableHydraulicBoundaryLocation) selectedItem; + return selected.HydraulicBoundaryLocation; + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/UITypeEditors/IHasHydraulicBoundaryLocationProperty.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Common/src/Ringtoets.Common.Forms/UITypeEditors/IHasHydraulicBoundaryLocationProperty.cs (.../IHasHydraulicBoundaryLocationProperty.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/UITypeEditors/IHasHydraulicBoundaryLocationProperty.cs (.../IHasHydraulicBoundaryLocationProperty.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -20,7 +20,9 @@ // All rights reserved. using System.Collections.Generic; +using Core.Common.Base.Geometry; using Core.Common.Gui.PropertyBag; +using Ringtoets.HydraRing.Data; namespace Ringtoets.Common.Forms.UITypeEditors { @@ -30,14 +32,19 @@ public interface IHasHydraulicBoundaryLocationProperty : IObjectProperties { /// - /// Gets the selectable hydraulic boundary location that is selected. + /// Gets the hydraulic boundary location that is selected. /// - SelectableHydraulicBoundaryLocation SelectedHydraulicBoundaryLocation { get; } + HydraulicBoundaryLocation SelectedHydraulicBoundaryLocation { get; } /// /// Returns the collection of selectable hydraulic boundary locations. /// /// A collection of selectable hydraulic boundary locations. - IEnumerable GetSelectableHydraulicBoundaryLocations(); + IEnumerable GetHydraulicBoundaryLocations(); + + /// + /// Returns the reference location from which the hydraulic boundary location needs to be calculated. + /// + Point2D GetReferenceLocation(); } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/UITypeEditors/SelectableHydraulicBoundaryLocation.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Common/src/Ringtoets.Common.Forms/UITypeEditors/SelectableHydraulicBoundaryLocation.cs (.../SelectableHydraulicBoundaryLocation.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/UITypeEditors/SelectableHydraulicBoundaryLocation.cs (.../SelectableHydraulicBoundaryLocation.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -27,8 +27,7 @@ namespace Ringtoets.Common.Forms.UITypeEditors { /// - /// Class that represents a in the drop down list edit control for the - /// collection of hydraulic boundary locations. + /// Class that represents a with respect to a reference point. /// public class SelectableHydraulicBoundaryLocation { @@ -112,7 +111,7 @@ return hydraulicBoundaryLocation.Name; } - return distance/1000 < 1 + return distance < 1000 ? string.Format("{0} ({1:f0} m)", hydraulicBoundaryLocation.Name, distance) : string.Format("{0} ({1:f1} km)", hydraulicBoundaryLocation.Name, distance/1000); } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs =================================================================== diff -u -r8528bae438c3eecedaa7d4010cacc93846dce2b5 -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 8528bae438c3eecedaa7d4010cacc93846dce2b5) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -124,190 +124,6 @@ } [Test] - public void SelectedHydraulicBoundaryLocation_InputNoLocation_DoesNotThrowExceptionAndReturnsNull() - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - var failureMechanismStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var calculation = new StructuresCalculation(); - var inputContext = new SimpleInputContext(calculation.InputParameters, - calculation, - failureMechanismStub, - assessmentSectionStub); - var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties()) - { - Data = inputContext - }; - - SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null; - - // Call - TestDelegate call = () => selectedHydraulicBoundaryLocation = properties.SelectedHydraulicBoundaryLocation; - - // Assert - Assert.DoesNotThrow(call); - Assert.IsNull(selectedHydraulicBoundaryLocation); - mockRepository.VerifyAll(); - } - - [Test] - public void GetSelectableHydraulicBoundaryLocations_InputWithLocationsAndNoStructure_ReturnsLocationsSortedByName() - { - // Setup - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - Locations = - { - new HydraulicBoundaryLocation(0, "A", 0, 1), - new HydraulicBoundaryLocation(0, "C", 0, 2), - new HydraulicBoundaryLocation(0, "D", 0, 3), - new HydraulicBoundaryLocation(0, "B", 0, 4) - } - }; - var assessmentSectionStub = mockRepository.Stub(); - var failureMechanismStub = mockRepository.Stub(); - - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - - mockRepository.ReplayAll(); - - var calculation = new StructuresCalculation(); - var inputContext = new SimpleInputContext(calculation.InputParameters, - calculation, - failureMechanismStub, - assessmentSectionStub); - var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties()) - { - Data = inputContext - }; - - // Call - var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); - - // Assert - IEnumerable expectedList = - hydraulicBoundaryDatabase.Locations - .Select(hbl => - new SelectableHydraulicBoundaryLocation(hbl, null)) - .OrderBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - mockRepository.VerifyAll(); - } - - [Test] - public void GetSelectableHydraulicBoundaryLocations_InputWithLocationsAndStructure_ReturnsLocationsSortByDistanceThenByName() - { - // Setup - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - Locations = - { - new HydraulicBoundaryLocation(0, "A", 0, 10), - new HydraulicBoundaryLocation(0, "E", 0, 500), - new HydraulicBoundaryLocation(0, "F", 0, 100), - new HydraulicBoundaryLocation(0, "D", 0, 200), - new HydraulicBoundaryLocation(0, "C", 0, 200), - new HydraulicBoundaryLocation(0, "B", 0, 200) - } - }; - var assessmentSectionStub = mockRepository.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - - var failureMechanismStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var calculation = new StructuresCalculation() - { - InputParameters = - { - Structure = new SimpleStructure() - } - }; - var inputContext = new SimpleInputContext(calculation.InputParameters, - calculation, - failureMechanismStub, - assessmentSectionStub); - var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties()) - { - Data = inputContext - }; - - // Call - var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); - - // Assert - IEnumerable expectedList = - hydraulicBoundaryDatabase.Locations - .Select(hbl => - new SelectableHydraulicBoundaryLocation( - hbl, calculation.InputParameters.Structure.Location)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - mockRepository.VerifyAll(); - } - - [Test] - public void GivenLocationAndReferencePoint_WhenUpdatingReferencePoint_ThenUpdateSelectableBoundaryLocations() - { - // Given - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - Locations = - { - new HydraulicBoundaryLocation(0, "A", 0, 10), - new HydraulicBoundaryLocation(0, "E", 0, 500), - new HydraulicBoundaryLocation(0, "F", 0, 100), - new HydraulicBoundaryLocation(0, "D", 0, 200), - new HydraulicBoundaryLocation(0, "C", 0, 200), - new HydraulicBoundaryLocation(0, "B", 0, 200) - } - }; - var assessmentSectionStub = mockRepository.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - var failureMechanismStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var calculation = new StructuresCalculation() - { - InputParameters = - { - Structure = new SimpleStructure() - } - }; - var inputContext = new SimpleInputContext(calculation.InputParameters, - calculation, - failureMechanismStub, - assessmentSectionStub); - var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties()) - { - Data = inputContext - }; - - IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations() - .ToList(); - - // When - properties.Structure = new SimpleStructure(new Point2D(0, 190)); - - // Then - IEnumerable availableHydraulicBoundaryLocations = - properties.GetSelectableHydraulicBoundaryLocations().ToList(); - CollectionAssert.AreNotEqual(originalList, availableHydraulicBoundaryLocations); - - IEnumerable expectedList = - hydraulicBoundaryDatabase.Locations - .Select(hbl => - new SelectableHydraulicBoundaryLocation(hbl, properties.StructureLocation)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - mockRepository.VerifyAll(); - } - - [Test] public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() { // Setup @@ -343,21 +159,20 @@ var newStructure = new SimpleStructure(); ForeshoreProfile newForeshoreProfile = new TestForeshoreProfile(); HydraulicBoundaryLocation newHydraulicBoundaryLocation = CreateHydraulicBoundaryLocation(); - var newSelectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(newHydraulicBoundaryLocation, null); // Call properties.Structure = newStructure; properties.StructureNormalOrientation = (RoundedDouble) newStructureNormalOrientation; properties.FailureProbabilityStructureWithErosion = "1e-2"; - properties.SelectedHydraulicBoundaryLocation = newSelectableHydraulicBoundaryLocation; + properties.SelectedHydraulicBoundaryLocation = newHydraulicBoundaryLocation; properties.ForeshoreProfile = newForeshoreProfile; // Assert Assert.AreSame(newStructure, properties.Structure); Assert.AreEqual(newStructureNormalOrientation, properties.StructureNormalOrientation, properties.StructureNormalOrientation.GetAccuracy()); Assert.AreEqual(0.01, inputContext.WrappedData.FailureProbabilityStructureWithErosion); Assert.AreEqual("1/100", properties.FailureProbabilityStructureWithErosion); - Assert.AreSame(newHydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(newHydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreSame(newForeshoreProfile, properties.ForeshoreProfile); mockRepository.VerifyAll(); } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/UITypeEditors/HydraulicBoundaryLocationEditorTest.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/UITypeEditors/HydraulicBoundaryLocationEditorTest.cs (.../HydraulicBoundaryLocationEditorTest.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/UITypeEditors/HydraulicBoundaryLocationEditorTest.cs (.../HydraulicBoundaryLocationEditorTest.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -22,7 +22,9 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Linq; using System.Windows.Forms.Design; +using Core.Common.Base.Geometry; using Core.Common.Gui.PropertyBag; using Core.Common.Gui.UITypeEditors; using NUnit.Framework; @@ -50,17 +52,17 @@ var editor = new HydraulicBoundaryLocationEditor(); // Assert - Assert.IsInstanceOf>(editor); + Assert.IsInstanceOf>(editor); } [Test] public void EditValue_WithCurrentItemNotInAvailableItems_ReturnsOriginalValue() { // Setup - SelectableHydraulicBoundaryLocation selectableHydraulicBoundaryLocationhydraulicBoundaryLocation = + HydraulicBoundaryLocation selectableHydraulicBoundaryLocationhydraulicBoundaryLocation = CreateSelectableHydraulicBoundaryLocation(); - var properties = new ObjectPropertiesWithSelectableHydraulicBoundaryLocation( - selectableHydraulicBoundaryLocationhydraulicBoundaryLocation, new SelectableHydraulicBoundaryLocation[0]); + var properties = new ObjectPropertiesWithHydraulicBoundaryLocation( + selectableHydraulicBoundaryLocationhydraulicBoundaryLocation, new HydraulicBoundaryLocation[0]); var propertyBag = new DynamicPropertyBag(properties); var editor = new HydraulicBoundaryLocationEditor(); var someValue = new object(); @@ -83,8 +85,8 @@ public void EditValue_WithCurrentItemInAvailableItems_ReturnsCurrentItem() { // Setup - SelectableHydraulicBoundaryLocation hydraulicBoundaryLocation = CreateSelectableHydraulicBoundaryLocation(); - var properties = new ObjectPropertiesWithSelectableHydraulicBoundaryLocation(hydraulicBoundaryLocation, new[] + HydraulicBoundaryLocation hydraulicBoundaryLocation = CreateSelectableHydraulicBoundaryLocation(); + var properties = new ObjectPropertiesWithHydraulicBoundaryLocation(hydraulicBoundaryLocation, new[] { hydraulicBoundaryLocation }); @@ -103,40 +105,179 @@ // Assert Assert.AreSame(hydraulicBoundaryLocation, result); + Assert.IsInstanceOf(result); mockRepository.VerifyAll(); } - private static SelectableHydraulicBoundaryLocation CreateSelectableHydraulicBoundaryLocation() + [Test] + public void GetAvailableOptions_InputWithLocationsAndNoReferencePoint_ReturnsLocationsSortedByName() { - return new SelectableHydraulicBoundaryLocation(new HydraulicBoundaryLocation(1, "", 0, 0), null); + // Setup + HydraulicBoundaryLocation hydraulicBoundaryLocation = CreateSelectableHydraulicBoundaryLocation(); + HydraulicBoundaryLocation[] locations = + { + hydraulicBoundaryLocation, + new HydraulicBoundaryLocation(0, "A", 0, 1), + new HydraulicBoundaryLocation(0, "C", 0, 2), + new HydraulicBoundaryLocation(0, "D", 0, 3), + new HydraulicBoundaryLocation(0, "B", 0, 4), + }; + + var properties = new ObjectPropertiesWithHydraulicBoundaryLocation(hydraulicBoundaryLocation, locations); + var propertyBag = new DynamicPropertyBag(properties); + + var editor = new TestHydraulicBoundaryLocationEditor(); + var descriptorContextStub = mockRepository.Stub(); + descriptorContextStub.Stub(c => c.Instance).Return(propertyBag); + mockRepository.ReplayAll(); + + // Call + IEnumerable availableHydraulicBoundaryLocations = + editor.GetItems(descriptorContextStub); + + // Assert + IEnumerable expectedList = + locations.Select(location => + new SelectableHydraulicBoundaryLocation(location, null)) + .OrderBy(hbl => hbl.HydraulicBoundaryLocation.Name); + CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); + mockRepository.VerifyAll(); } - private class ObjectPropertiesWithSelectableHydraulicBoundaryLocation : IHasHydraulicBoundaryLocationProperty + [Test] + public void GetAvailableOptions_InputWithLocationsAndReferencePoint_ReturnsLocationsSortedByDistanceThenByName() { - private readonly SelectableHydraulicBoundaryLocation selectableHydraulicBoundaryLocation; - private readonly IEnumerable selectableHydraulicBoundaryLocations; + // Setup + HydraulicBoundaryLocation hydraulicBoundaryLocation = CreateSelectableHydraulicBoundaryLocation(); + HydraulicBoundaryLocation[] locations = + { + hydraulicBoundaryLocation, + new HydraulicBoundaryLocation(0, "A", 0, 10), + new HydraulicBoundaryLocation(0, "E", 0, 500), + new HydraulicBoundaryLocation(0, "F", 0, 100), + new HydraulicBoundaryLocation(0, "D", 0, 200), + new HydraulicBoundaryLocation(0, "C", 0, 200), + new HydraulicBoundaryLocation(0, "B", 0, 200) + }; - public ObjectPropertiesWithSelectableHydraulicBoundaryLocation(SelectableHydraulicBoundaryLocation selectableHydraulicBoundaryLocation, - IEnumerable selectableHydraulicBoundaryLocations) + var properties = new ObjectPropertiesWithHydraulicBoundaryLocation(hydraulicBoundaryLocation, locations) { - this.selectableHydraulicBoundaryLocation = selectableHydraulicBoundaryLocation; + ReferencePoint = new Point2D(0, 0) + }; + var propertyBag = new DynamicPropertyBag(properties); + + var editor = new TestHydraulicBoundaryLocationEditor(); + var descriptorContextStub = mockRepository.Stub(); + descriptorContextStub.Stub(c => c.Instance).Return(propertyBag); + mockRepository.ReplayAll(); + + // Call + IEnumerable availableHydraulicBoundaryLocations = + editor.GetItems(descriptorContextStub); + + // Assert + IEnumerable expectedList = + locations.Select(location => + new SelectableHydraulicBoundaryLocation(location, properties.ReferencePoint)) + .OrderBy(hbl => hbl.Distance.Value) + .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); + CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); + mockRepository.VerifyAll(); + } + + [Test] + public void GivenLocationAndReferencePoint_WhenUpdatingReferencePoint_ThenUpdateSelectableBoundaryLocations() + { + // Given + HydraulicBoundaryLocation hydraulicBoundaryLocation = CreateSelectableHydraulicBoundaryLocation(); + HydraulicBoundaryLocation[] locations = + { + hydraulicBoundaryLocation, + new HydraulicBoundaryLocation(0, "A", 0, 10), + new HydraulicBoundaryLocation(0, "E", 0, 500), + new HydraulicBoundaryLocation(0, "F", 0, 100), + new HydraulicBoundaryLocation(0, "D", 0, 200), + new HydraulicBoundaryLocation(0, "C", 0, 200), + new HydraulicBoundaryLocation(0, "B", 0, 200) + }; + + var properties = new ObjectPropertiesWithHydraulicBoundaryLocation(hydraulicBoundaryLocation, locations) + { + ReferencePoint = new Point2D(0, 0) + }; + var propertyBag = new DynamicPropertyBag(properties); + + var editor = new TestHydraulicBoundaryLocationEditor(); + var descriptorContextStub = mockRepository.Stub(); + descriptorContextStub.Stub(c => c.Instance).Return(propertyBag); + mockRepository.ReplayAll(); + + IEnumerable originalList = + editor.GetItems(descriptorContextStub).ToList(); + + // When + properties.ReferencePoint = new Point2D(0, 190); + + // Then + IEnumerable availableHydraulicBoundaryLocations = + editor.GetItems(descriptorContextStub).ToList(); + CollectionAssert.AreNotEqual(originalList, availableHydraulicBoundaryLocations); + + IEnumerable expectedList = + locations.Select(hbl => + new SelectableHydraulicBoundaryLocation(hbl, properties.ReferencePoint)) + .OrderBy(hbl => hbl.Distance.Value) + .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); + CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); + mockRepository.VerifyAll(); + } + + private static HydraulicBoundaryLocation CreateSelectableHydraulicBoundaryLocation() + { + return new HydraulicBoundaryLocation(1, "", 0, 0); + } + + private class ObjectPropertiesWithHydraulicBoundaryLocation : IHasHydraulicBoundaryLocationProperty + { + private readonly HydraulicBoundaryLocation selectedHydraulicBoundaryLocation; + private readonly IEnumerable selectableHydraulicBoundaryLocations; + + public ObjectPropertiesWithHydraulicBoundaryLocation(HydraulicBoundaryLocation selectedHydraulicBoundaryLocation, + IEnumerable selectableHydraulicBoundaryLocations) + { + this.selectedHydraulicBoundaryLocation = selectedHydraulicBoundaryLocation; this.selectableHydraulicBoundaryLocations = selectableHydraulicBoundaryLocations; } public object Data { get; set; } - public SelectableHydraulicBoundaryLocation SelectedHydraulicBoundaryLocation + public Point2D ReferencePoint { get; set; } + + public HydraulicBoundaryLocation SelectedHydraulicBoundaryLocation { get { - return selectableHydraulicBoundaryLocation; + return selectedHydraulicBoundaryLocation; } } - public IEnumerable GetSelectableHydraulicBoundaryLocations() + public IEnumerable GetHydraulicBoundaryLocations() { return selectableHydraulicBoundaryLocations; } + + public Point2D GetReferenceLocation() + { + return ReferencePoint; + } } + + private class TestHydraulicBoundaryLocationEditor : HydraulicBoundaryLocationEditor + { + public IEnumerable GetItems(ITypeDescriptorContext context) + { + return GetAvailableOptions(context); + } + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -22,7 +22,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; -using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Gui.Attributes; @@ -35,6 +34,7 @@ using Ringtoets.GrassCoverErosionInwards.Forms.Properties; using Ringtoets.GrassCoverErosionInwards.Forms.UITypeEditors; using Ringtoets.GrassCoverErosionInwards.Utils; +using Ringtoets.HydraRing.Data; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.GrassCoverErosionInwards.Forms.PropertyClasses @@ -208,17 +208,15 @@ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_HydraulicData")] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "HydraulicBoundaryLocation_DisplayName")] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "HydraulicBoundaryLocation_Description")] - public SelectableHydraulicBoundaryLocation SelectedHydraulicBoundaryLocation + public HydraulicBoundaryLocation SelectedHydraulicBoundaryLocation { get { - return data.WrappedData.HydraulicBoundaryLocation != null - ? new SelectableHydraulicBoundaryLocation(data.WrappedData.HydraulicBoundaryLocation, WorldReferencePoint) - : null; + return data.WrappedData.HydraulicBoundaryLocation; } set { - data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation; + data.WrappedData.HydraulicBoundaryLocation = value; data.WrappedData.NotifyObservers(); } } @@ -238,14 +236,16 @@ return data.AvailableDikeProfiles; } - public IEnumerable GetSelectableHydraulicBoundaryLocations() + public Point2D GetReferenceLocation() { - var calculationLocation = data.WrappedData.DikeProfile != null ? data.WrappedData.DikeProfile.WorldReferencePoint : null; + return data.WrappedData.DikeProfile != null + ? data.WrappedData.DikeProfile.WorldReferencePoint + : null; + } - return data.AvailableHydraulicBoundaryLocations - .Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, calculationLocation)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); + public IEnumerable GetHydraulicBoundaryLocations() + { + return data.AvailableHydraulicBoundaryLocations; } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs =================================================================== diff -u -r8528bae438c3eecedaa7d4010cacc93846dce2b5 -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 8528bae438c3eecedaa7d4010cacc93846dce2b5) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -142,7 +142,7 @@ Assert.AreEqual(0.0, properties.DikeHeight.Value); Assert.AreEqual(input.CriticalFlowRate.Mean, properties.CriticalFlowRate.Mean); Assert.AreEqual(input.CriticalFlowRate.StandardDeviation, properties.CriticalFlowRate.StandardDeviation); - Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreEqual(input.CalculateDikeHeight, properties.CalculateDikeHeight); Assert.AreEqual(new Point2D(12, 57), properties.WorldReferencePoint); mockRepository.VerifyAll(); @@ -170,193 +170,25 @@ DikeProfile newDikeProfile = new TestDikeProfile(); var newDikeHeight = new RoundedDouble(2, 9); var newOrientation = new RoundedDouble(2, 5); - var newSelectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation( - new HydraulicBoundaryLocation(0, "name", 0.0, 1.1), null); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "name", 0.0, 1.1); // Call properties.DikeProfile = newDikeProfile; properties.Orientation = newOrientation; properties.DikeHeight = newDikeHeight; - properties.SelectedHydraulicBoundaryLocation = newSelectableHydraulicBoundaryLocation; + properties.SelectedHydraulicBoundaryLocation = hydraulicBoundaryLocation; properties.CalculateDikeHeight = true; // Assert Assert.AreSame(newDikeProfile, input.DikeProfile); Assert.AreEqual(newOrientation, input.Orientation); Assert.AreEqual(newDikeHeight, input.DikeHeight); - Assert.AreSame(newSelectableHydraulicBoundaryLocation.HydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + Assert.AreSame(hydraulicBoundaryLocation, input.HydraulicBoundaryLocation); Assert.IsTrue(input.CalculateDikeHeight); mockRepository.VerifyAll(); } [Test] - public void SelectedHydraulicBoundaryLocation_InputNoLocation_DoesNotThrowExceptionAndReturnsNull() - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var calculationInput = new GrassCoverErosionInwardsInput(); - var calculation = new GrassCoverErosionInwardsCalculation(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var inputContext = new GrassCoverErosionInwardsInputContext(calculationInput, - calculation, - failureMechanism, - assessmentSectionStub); - var properties = new GrassCoverErosionInwardsInputContextProperties - { - Data = inputContext - }; - - SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null; - - // Call - TestDelegate call = () => selectedHydraulicBoundaryLocation = properties.SelectedHydraulicBoundaryLocation; - - // Assert - Assert.DoesNotThrow(call); - Assert.IsNull(selectedHydraulicBoundaryLocation); - mockRepository.VerifyAll(); - } - - [Test] - public void GetSelectableHydraulicBoundaryLocations_InputWithLocationsAndNoDikeProfile_ReturnsLocationsSortedByName() - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - Locations = - { - new HydraulicBoundaryLocation(0, "A", 0, 1), - new HydraulicBoundaryLocation(0, "C", 0, 2), - new HydraulicBoundaryLocation(0, "D", 0, 3), - new HydraulicBoundaryLocation(0, "B", 0, 4), - } - }; - mockRepository.ReplayAll(); - - var input = new GrassCoverErosionInwardsInput(); - var calculation = new GrassCoverErosionInwardsCalculation(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var properties = new GrassCoverErosionInwardsInputContextProperties - { - Data = new GrassCoverErosionInwardsInputContext(input, calculation, failureMechanism, assessmentSectionStub) - }; - - // Call - IEnumerable availableHydraulicBoundaryLocations = - properties.GetSelectableHydraulicBoundaryLocations(); - - // Assert - IEnumerable expectedList = - assessmentSectionStub.HydraulicBoundaryDatabase.Locations - .Select(location => - new SelectableHydraulicBoundaryLocation(location, null)) - .OrderBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - mockRepository.VerifyAll(); - } - - [Test] - public void GetSelectableHydraulicBoundaryLocations_InputWithLocationsAndNoDikeProfile_ReturnsLocationsSortedByDistanceThenByName() - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - Locations = - { - new HydraulicBoundaryLocation(0, "A", 0, 10), - new HydraulicBoundaryLocation(0, "E", 0, 500), - new HydraulicBoundaryLocation(0, "F", 0, 100), - new HydraulicBoundaryLocation(0, "D", 0, 200), - new HydraulicBoundaryLocation(0, "C", 0, 200), - new HydraulicBoundaryLocation(0, "B", 0, 200) - } - }; - mockRepository.ReplayAll(); - - var input = new GrassCoverErosionInwardsInput() - { - DikeProfile = new TestDikeProfile() - }; - var calculation = new GrassCoverErosionInwardsCalculation(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var properties = new GrassCoverErosionInwardsInputContextProperties - { - Data = new GrassCoverErosionInwardsInputContext(input, calculation, failureMechanism, assessmentSectionStub) - }; - - // Call - IEnumerable availableHydraulicBoundaryLocations = - properties.GetSelectableHydraulicBoundaryLocations(); - - // Assert - IEnumerable expectedList = - assessmentSectionStub.HydraulicBoundaryDatabase.Locations - .Select(location => - new SelectableHydraulicBoundaryLocation( - location, input.DikeProfile.WorldReferencePoint)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - mockRepository.VerifyAll(); - } - - [Test] - public void GivenLocationAndReferencePoint_WhenUpdatingReferencePoint_ThenUpdateSelectableBoundaryLocations() - { - // Given - var assessmentSectionStub = mockRepository.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase - { - Locations = - { - new HydraulicBoundaryLocation(0, "A", 0, 10), - new HydraulicBoundaryLocation(0, "E", 0, 500), - new HydraulicBoundaryLocation(0, "F", 0, 100), - new HydraulicBoundaryLocation(0, "D", 0, 200), - new HydraulicBoundaryLocation(0, "C", 0, 200), - new HydraulicBoundaryLocation(0, "B", 0, 200) - } - }; - mockRepository.ReplayAll(); - - var input = new GrassCoverErosionInwardsInput() - { - DikeProfile = new TestDikeProfile() - }; - var calculation = new GrassCoverErosionInwardsCalculation(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var properties = new GrassCoverErosionInwardsInputContextProperties - { - Data = new GrassCoverErosionInwardsInputContext(input, calculation, failureMechanism, assessmentSectionStub) - }; - - IEnumerable originalList = - properties.GetSelectableHydraulicBoundaryLocations().ToList(); - - // When - properties.DikeProfile = new TestDikeProfile(new Point2D(0.0, 190.0)); - - // Then - IEnumerable availableHydraulicBoundaryLocations = - properties.GetSelectableHydraulicBoundaryLocations().ToList(); - CollectionAssert.AreNotEqual(originalList, availableHydraulicBoundaryLocations); - - IEnumerable expectedList = - assessmentSectionStub.HydraulicBoundaryDatabase.Locations - .Select(hbl => - new SelectableHydraulicBoundaryLocation(hbl, - properties.DikeProfile.WorldReferencePoint)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - mockRepository.VerifyAll(); - } - - [Test] public void GetAvailableDikeProfiles_InputWithDikeProfiles_ReturnsDikeProfiles() { // Setup Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs (.../GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs (.../GrassCoverErosionOutwardsWaveConditionsInputContextPropertiesTest.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -33,7 +33,6 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PropertyClasses; -using Ringtoets.Common.Forms.UITypeEditors; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionOutwards.Forms.PropertyClasses; @@ -167,7 +166,7 @@ }; // Assert - Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreEqual(assessmentLevel.Value, properties.AssessmentLevel.Value, properties.AssessmentLevel.GetAccuracy()); Assert.AreSame(foreshoreProfile, properties.ForeshoreProfile); Assert.AreEqual(worldX, properties.WorldReferencePoint.X, 0.5); @@ -202,7 +201,6 @@ { DesignWaterLevel = assessmentLevel }; - var newSelectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(newHydraulicBoundaryLocation, null); var input = new WaveConditionsInput(); input.Attach(observerMock); @@ -230,11 +228,11 @@ properties.UpperBoundaryWaterLevels = newUpperBoundaryWaterLevels; properties.LowerBoundaryWaterLevels = newLowerBoundaryWaterLevels; properties.StepSize = newStepSize; - properties.SelectedHydraulicBoundaryLocation = newSelectableHydraulicBoundaryLocation; + properties.SelectedHydraulicBoundaryLocation = newHydraulicBoundaryLocation; properties.Orientation = orientation; // Assert - Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreEqual(input.HydraulicBoundaryLocation.DesignWaterLevel.Value, properties.AssessmentLevel.Value); Assert.AreEqual(assessmentLevel - 0.01, properties.UpperBoundaryDesignWaterLevel.Value, properties.UpperBoundaryDesignWaterLevel.GetAccuracy()); Assert.AreEqual(2, properties.UpperBoundaryDesignWaterLevel.NumberOfDecimalPlaces); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -22,13 +22,13 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; -using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Forms.UITypeEditors; +using Ringtoets.HydraRing.Data; using Ringtoets.Piping.Data; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Properties; @@ -74,13 +74,14 @@ return data.WrappedData.StochasticSoilModel != null ? data.WrappedData.StochasticSoilModel.StochasticSoilProfiles : new List(); } - public IEnumerable GetSelectableHydraulicBoundaryLocations() + public Point2D GetReferenceLocation() { - Point2D referencePoint = SurfaceLine != null ? SurfaceLine.ReferenceLineIntersectionWorldPoint : null; + return SurfaceLine != null ? SurfaceLine.ReferenceLineIntersectionWorldPoint : null; + } - return data.AvailableHydraulicBoundaryLocations.Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, referencePoint)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); + public IEnumerable GetHydraulicBoundaryLocations() + { + return data.AvailableHydraulicBoundaryLocations; } #region Hydraulic data @@ -89,20 +90,15 @@ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_HydraulicData")] [ResourcesDisplayName(typeof(Resources), "PipingInput_HydraulicBoundaryLocation_DisplayName")] [ResourcesDescription(typeof(Resources), "PipingInput_HydraulicBoundaryLocation_Description")] - public SelectableHydraulicBoundaryLocation SelectedHydraulicBoundaryLocation + public HydraulicBoundaryLocation SelectedHydraulicBoundaryLocation { get { - Point2D referencePoint = SurfaceLine != null ? SurfaceLine.ReferenceLineIntersectionWorldPoint : null; - - return data.WrappedData.HydraulicBoundaryLocation != null - ? new SelectableHydraulicBoundaryLocation(data.WrappedData.HydraulicBoundaryLocation, - referencePoint) - : null; + return data.WrappedData.HydraulicBoundaryLocation; } set { - data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation; + data.WrappedData.HydraulicBoundaryLocation = value; data.WrappedData.NotifyObservers(); } } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs =================================================================== diff -u -r8528bae438c3eecedaa7d4010cacc93846dce2b5 -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 8528bae438c3eecedaa7d4010cacc93846dce2b5) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -297,7 +297,7 @@ Assert.AreSame(surfaceLine, properties.SurfaceLine); Assert.AreSame(stochasticSoilProfile, properties.StochasticSoilProfile); Assert.AreSame(stochasticSoilModel, properties.StochasticSoilModel); - Assert.AreSame(testHydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(testHydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); mocks.VerifyAll(); } @@ -393,8 +393,7 @@ SurfaceLine = surfaceLine, StochasticSoilModel = stochasticSoilModel2, StochasticSoilProfile = stochasticSoilProfile2, - SelectedHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation( - new TestHydraulicBoundaryLocation(assessmentLevel), null) + SelectedHydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(assessmentLevel) }; // Assert @@ -706,10 +705,9 @@ { DesignWaterLevel = RoundedDouble.NaN }; - var selectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(hydraulicBoundaryLocation, null); // Call - properties.SelectedHydraulicBoundaryLocation = selectableHydraulicBoundaryLocation; + properties.SelectedHydraulicBoundaryLocation = hydraulicBoundaryLocation; // Assert Assert.IsNaN(properties.AssessmentLevel.Value); @@ -748,10 +746,9 @@ { DesignWaterLevel = testLevel }; - var selectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(hydraulicBoundaryLocation, null); // Call - properties.SelectedHydraulicBoundaryLocation = selectableHydraulicBoundaryLocation; + properties.SelectedHydraulicBoundaryLocation = hydraulicBoundaryLocation; // Assert Assert.AreEqual(testLevel, properties.AssessmentLevel, properties.AssessmentLevel.GetAccuracy()); @@ -1203,186 +1200,6 @@ mocks.VerifyAll(); } - [Test] - public void SelectedHydraulicBoundaryLocation_InputNoLocation_DoesNotThrowExceptionAndReturnsNull() - { - // Setup - var mocks = new MockRepository(); - var assessmentSectionStub = mocks.Stub(); - mocks.ReplayAll(); - - var failureMechanism = new PipingFailureMechanism(); - var calculation = new PipingCalculationScenario(failureMechanism.GeneralInput); - var context = new PipingInputContext(calculation.InputParameters, calculation, - failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, - failureMechanism, assessmentSectionStub); - var properties = new PipingInputContextProperties - { - Data = context - }; - - SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null; - - // Call - TestDelegate call = () => selectedHydraulicBoundaryLocation = properties.SelectedHydraulicBoundaryLocation; - - // Assert - Assert.DoesNotThrow(call); - Assert.IsNull(selectedHydraulicBoundaryLocation); - mocks.VerifyAll(); - } - - [Test] - public void GetSelectableHydraulicBoundaryLocations_WithLocationsNoSurfaceLine_ReturnLocationsSortedByName() - { - // Setup - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() - { - Locations = - { - new HydraulicBoundaryLocation(0, "A", 0, 1), - new HydraulicBoundaryLocation(0, "C", 0, 2), - new HydraulicBoundaryLocation(0, "D", 0, 3), - new HydraulicBoundaryLocation(0, "B", 0, 4) - } - }; - - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - mocks.ReplayAll(); - - var failureMechanism = new PipingFailureMechanism(); - var calculation = new PipingCalculationScenario(failureMechanism.GeneralInput); - var context = new PipingInputContext(calculation.InputParameters, calculation, - failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, - failureMechanism, assessmentSection); - var properties = new PipingInputContextProperties - { - Data = context - }; - - // Call - IEnumerable selectableHydraulicBoundaryLocations = - properties.GetSelectableHydraulicBoundaryLocations(); - - // Assert - IEnumerable expectedList = - hydraulicBoundaryDatabase.Locations.Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, null)) - .OrderBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, selectableHydraulicBoundaryLocations); - mocks.VerifyAll(); - } - - [Test] - public void GetSelectableHydraulicBoundaryLocations_WithLocationsAndSurfaceLine_ReturnLocationsSortedByDistanceThenByName() - { - // Setup - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() - { - Locations = - { - new HydraulicBoundaryLocation(0, "A", 0, 10), - new HydraulicBoundaryLocation(0, "E", 0, 500), - new HydraulicBoundaryLocation(0, "F", 0, 100), - new HydraulicBoundaryLocation(0, "D", 0, 200), - new HydraulicBoundaryLocation(0, "C", 0, 200), - new HydraulicBoundaryLocation(0, "B", 0, 200) - } - }; - - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - mocks.ReplayAll(); - - var failureMechanism = new PipingFailureMechanism(); - var calculation = new PipingCalculationScenario(failureMechanism.GeneralInput); - var context = new PipingInputContext(calculation.InputParameters, calculation, - failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, - failureMechanism, assessmentSection); - RingtoetsPipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); - surfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0.0, 0.0); - var properties = new PipingInputContextProperties - { - Data = context, - SurfaceLine = surfaceLine - }; - - // Call - IEnumerable selectableHydraulicBoundaryLocations = - properties.GetSelectableHydraulicBoundaryLocations(); - - // Assert - IEnumerable expectedList = - hydraulicBoundaryDatabase.Locations.Select(hbl => new SelectableHydraulicBoundaryLocation( - hbl, surfaceLine.ReferenceLineIntersectionWorldPoint)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, selectableHydraulicBoundaryLocations); - mocks.VerifyAll(); - } - - [Test] - public void GivenLocationAndReferencePoint_WhenUpdatingReferencePoint_ThenUpdateSelectableBoundaryLocations() - { - // Given - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() - { - Locations = - { - new HydraulicBoundaryLocation(0, "A", 0, 10), - new HydraulicBoundaryLocation(0, "E", 0, 500), - new HydraulicBoundaryLocation(0, "F", 0, 100), - new HydraulicBoundaryLocation(0, "D", 0, 200), - new HydraulicBoundaryLocation(0, "C", 0, 200), - new HydraulicBoundaryLocation(0, "B", 0, 200) - } - }; - - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - mocks.ReplayAll(); - - var failureMechanism = new PipingFailureMechanism(); - var calculation = new PipingCalculationScenario(failureMechanism.GeneralInput); - var context = new PipingInputContext(calculation.InputParameters, calculation, - failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, - failureMechanism, assessmentSection); - var surfaceLine = ValidSurfaceLine(0.0, 4.0); - surfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0, 0); - var properties = new PipingInputContextProperties - { - Data = context, - SurfaceLine = surfaceLine - }; - - IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations() - .ToList(); - - var newSurfaceLine = ValidSurfaceLine(0.0, 5.0); - newSurfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0, 190); - - // When - properties.SurfaceLine = newSurfaceLine; - - // Then - IEnumerable availableHydraulicBoundaryLocations = - properties.GetSelectableHydraulicBoundaryLocations().ToList(); - CollectionAssert.AreNotEqual(originalList, availableHydraulicBoundaryLocations); - - IEnumerable expectedList = - hydraulicBoundaryDatabase.Locations - .Select(hbl => - new SelectableHydraulicBoundaryLocation(hbl, - properties.SurfaceLine.ReferenceLineIntersectionWorldPoint)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - mocks.VerifyAll(); - } - private static StochasticSoilModel ValidStochasticSoilModel(double xMin, double xMax) { StochasticSoilModel stochasticSoilModel = new StochasticSoilModel(0, "StochasticSoilModelName", "StochasticSoilModelSegmentName"); Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -33,6 +33,7 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.UITypeEditors; +using Ringtoets.HydraRing.Data; using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Forms.PresentationObjects; using Ringtoets.Revetment.Forms.Properties; @@ -277,18 +278,15 @@ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_HydraulicData")] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "HydraulicBoundaryLocation_DisplayName")] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "HydraulicBoundaryLocation_Description")] - public virtual SelectableHydraulicBoundaryLocation SelectedHydraulicBoundaryLocation + public virtual HydraulicBoundaryLocation SelectedHydraulicBoundaryLocation { get { - return data.WrappedData.HydraulicBoundaryLocation != null - ? new SelectableHydraulicBoundaryLocation(data.WrappedData.HydraulicBoundaryLocation, - WorldReferencePoint) - : null; + return data.WrappedData.HydraulicBoundaryLocation; } set { - data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation; + data.WrappedData.HydraulicBoundaryLocation = value; data.WrappedData.NotifyObservers(); } } @@ -298,12 +296,16 @@ return data.ForeshoreProfiles; } - public virtual IEnumerable GetSelectableHydraulicBoundaryLocations() + public Point2D GetReferenceLocation() { - return data.HydraulicBoundaryLocations - .Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, WorldReferencePoint)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); + return data.WrappedData.ForeshoreProfile != null + ? data.WrappedData.ForeshoreProfile.WorldReferencePoint + : null; } + + public virtual IEnumerable GetHydraulicBoundaryLocations() + { + return data.HydraulicBoundaryLocations; + } } } \ No newline at end of file Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -r8528bae438c3eecedaa7d4010cacc93846dce2b5 -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 8528bae438c3eecedaa7d4010cacc93846dce2b5) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -168,7 +168,7 @@ }; // Assert - Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreEqual(assessmentLevel.Value, properties.AssessmentLevel.Value, properties.AssessmentLevel.GetAccuracy()); Assert.AreSame(foreshoreProfile, properties.ForeshoreProfile); Assert.AreEqual(worldX, properties.WorldReferencePoint.X, 0.5); @@ -203,7 +203,6 @@ { DesignWaterLevel = assessmentLevel }; - var selectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(hydraulicBoundaryLocation, null); var input = new WaveConditionsInput(); input.Attach(observerMock); @@ -229,11 +228,11 @@ properties.UpperBoundaryWaterLevels = newUpperBoundaryWaterLevels; properties.LowerBoundaryWaterLevels = newLowerBoundaryWaterLevels; properties.StepSize = newStepSize; - properties.SelectedHydraulicBoundaryLocation = selectableHydraulicBoundaryLocation; + properties.SelectedHydraulicBoundaryLocation = hydraulicBoundaryLocation; properties.Orientation = orientation; // Assert - Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreEqual(input.HydraulicBoundaryLocation.DesignWaterLevel.Value, properties.AssessmentLevel.Value); Assert.AreEqual(assessmentLevel - 0.01, properties.UpperBoundaryDesignWaterLevel.Value, properties.UpperBoundaryDesignWaterLevel.GetAccuracy()); Assert.AreEqual(2, properties.UpperBoundaryDesignWaterLevel.NumberOfDecimalPlaces); @@ -252,138 +251,6 @@ } [Test] - public void SelectedHydraulicBoundaryLocation_InputNoLocation_DoesNotThrowExceptionAndReturnsNull() - { - var input = new WaveConditionsInput(); - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); - - var properties = new TestWaveConditionsInputContextProperties - { - Data = inputContext - }; - - SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null; - - // Call - TestDelegate call = () => selectedHydraulicBoundaryLocation = properties.SelectedHydraulicBoundaryLocation; - - // Assert - Assert.DoesNotThrow(call); - Assert.IsNull(selectedHydraulicBoundaryLocation); - } - - [Test] - public void GetSelectableHydraulicBoundaryLocations_InputWithLocationsNoReferencePoint_ReturnsLocationsSortedByName() - { - // Setup - var locations = new List() - { - new HydraulicBoundaryLocation(0, "A", 0, 1), - new HydraulicBoundaryLocation(0, "C", 0, 2), - new HydraulicBoundaryLocation(0, "D", 0, 3), - new HydraulicBoundaryLocation(0, "B", 0, 4) - }; - - var input = new WaveConditionsInput(); - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - - var properties = new TestWaveConditionsInputContextProperties - { - Data = inputContext - }; - - // Call - var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); - - // Assert - IEnumerable expectedList = - locations.Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, null)) - .OrderBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - } - - [Test] - public void GetSelectableHydraulicBoundaryLocations_InputWithLocationsAndReferencePoint_ReturnsLocationsSortedByDistanceThenByName() - { - // Setup - var locations = new List() - { - new HydraulicBoundaryLocation(0, "A", 0, 10), - new HydraulicBoundaryLocation(0, "E", 0, 500), - new HydraulicBoundaryLocation(0, "F", 0, 100), - new HydraulicBoundaryLocation(0, "D", 0, 200), - new HydraulicBoundaryLocation(0, "C", 0, 200), - new HydraulicBoundaryLocation(0, "B", 0, 200) - }; - - var input = new WaveConditionsInput() - { - ForeshoreProfile = new TestForeshoreProfile(string.Empty) - }; - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - - var properties = new TestWaveConditionsInputContextProperties - { - Data = inputContext - }; - - // Call - var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); - - // Assert - IEnumerable expectedList = - locations.Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, input.ForeshoreProfile.WorldReferencePoint)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - } - - [Test] - public void GivenLocationAndReferencePoint_WhenUpdatingReferencePoint_ThenUpdateSelectableBoundaryLocations() - { - // Given - var locations = new List() - { - new HydraulicBoundaryLocation(0, "A", 0, 10), - new HydraulicBoundaryLocation(0, "E", 0, 500), - new HydraulicBoundaryLocation(0, "F", 0, 100), - new HydraulicBoundaryLocation(0, "D", 0, 200), - new HydraulicBoundaryLocation(0, "C", 0, 200), - new HydraulicBoundaryLocation(0, "B", 0, 200) - }; - - var input = new WaveConditionsInput() - { - ForeshoreProfile = new TestForeshoreProfile(string.Empty) - }; - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - - var properties = new TestWaveConditionsInputContextProperties - { - Data = inputContext - }; - - IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations() - .ToList(); - - // When - properties.ForeshoreProfile = new TestForeshoreProfile(new Point2D(0, 190)); - - // Then - IEnumerable availableHydraulicBoundaryLocations = - properties.GetSelectableHydraulicBoundaryLocations().ToList(); - CollectionAssert.AreNotEqual(originalList, availableHydraulicBoundaryLocations); - - IEnumerable expectedList = - locations.Select(hbl => - new SelectableHydraulicBoundaryLocation(hbl, - properties.ForeshoreProfile.WorldReferencePoint)) - .OrderBy(hbl => hbl.Distance.Value) - .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); - CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); - } - - [Test] public void GetAvailableForeshoreProfiles_InputWithLocations_ReturnsLocations() { // Setup Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs (.../StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs (.../StabilityStoneCoverWaveConditionsInputContextPropertiesTest.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -34,7 +34,6 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PropertyClasses; -using Ringtoets.Common.Forms.UITypeEditors; using Ringtoets.HydraRing.Data; using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Forms.PropertyClasses; @@ -188,7 +187,7 @@ }; // Assert - Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreEqual(assessmentLevel.Value, properties.AssessmentLevel.Value, properties.AssessmentLevel.GetAccuracy()); Assert.AreSame(foreshoreProfile, properties.ForeshoreProfile); Assert.AreEqual(worldX, properties.WorldReferencePoint.X, 0.5); @@ -225,7 +224,6 @@ { DesignWaterLevel = assessmentLevel }; - var newSelectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(newHydraulicBoundaryLocation, null); assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -264,11 +262,11 @@ properties.UpperBoundaryWaterLevels = newUpperBoundaryWaterLevels; properties.LowerBoundaryWaterLevels = newLowerBoundaryWaterLevels; properties.StepSize = newStepSize; - properties.SelectedHydraulicBoundaryLocation = newSelectableHydraulicBoundaryLocation; + properties.SelectedHydraulicBoundaryLocation = newHydraulicBoundaryLocation; properties.Orientation = orientation; // Assert - Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreEqual(input.HydraulicBoundaryLocation.DesignWaterLevel.Value, properties.AssessmentLevel.Value); Assert.AreEqual(assessmentLevel - 0.01, properties.UpperBoundaryDesignWaterLevel.Value, properties.UpperBoundaryDesignWaterLevel.GetAccuracy()); Assert.AreEqual(2, properties.UpperBoundaryDesignWaterLevel.NumberOfDecimalPlaces); Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -r603abf1f7f49b0ed6d179e7dd800a170048f477d -rcc2b4067500d40bf504c7c4b3b076061cc390af4 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs (.../WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs) (revision 603abf1f7f49b0ed6d179e7dd800a170048f477d) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs (.../WaveImpactAsphaltCoverWaveConditionsInputContextPropertiesTest.cs) (revision cc2b4067500d40bf504c7c4b3b076061cc390af4) @@ -34,7 +34,6 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PropertyClasses; -using Ringtoets.Common.Forms.UITypeEditors; using Ringtoets.HydraRing.Data; using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Forms.PropertyClasses; @@ -188,7 +187,7 @@ }; // Assert - Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreEqual(assessmentLevel.Value, properties.AssessmentLevel.Value, properties.AssessmentLevel.GetAccuracy()); Assert.AreSame(foreshoreProfile, properties.ForeshoreProfile); Assert.AreEqual(worldX, properties.WorldReferencePoint.X, 0.5); @@ -225,8 +224,6 @@ { DesignWaterLevel = assessmentLevel }; - var newSelectableHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(newHydraulicBoundaryLocation, null); - assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { Locations = @@ -263,12 +260,12 @@ properties.LowerBoundaryRevetment = newLowerBoundaryRevetment; properties.UpperBoundaryWaterLevels = newUpperBoundaryWaterLevels; properties.LowerBoundaryWaterLevels = newLowerBoundaryWaterLevels; + properties.SelectedHydraulicBoundaryLocation = newHydraulicBoundaryLocation; properties.StepSize = newStepSize; - properties.SelectedHydraulicBoundaryLocation = newSelectableHydraulicBoundaryLocation; properties.Orientation = orientation; // Assert - Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation); Assert.AreEqual(input.HydraulicBoundaryLocation.DesignWaterLevel.Value, properties.AssessmentLevel.Value); Assert.AreEqual(assessmentLevel - 0.01, properties.UpperBoundaryDesignWaterLevel.Value, properties.UpperBoundaryDesignWaterLevel.GetAccuracy()); Assert.AreEqual(2, properties.UpperBoundaryDesignWaterLevel.NumberOfDecimalPlaces);