Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs =================================================================== diff -u -r89774b7d8b41c979aa51de68ccd318352c4199aa -r8528bae438c3eecedaa7d4010cacc93846dce2b5 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 89774b7d8b41c979aa51de68ccd318352c4199aa) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 8528bae438c3eecedaa7d4010cacc93846dce2b5) @@ -209,7 +209,7 @@ new HydraulicBoundaryLocation(0, "F", 0, 100), new HydraulicBoundaryLocation(0, "D", 0, 200), new HydraulicBoundaryLocation(0, "C", 0, 200), - new HydraulicBoundaryLocation(0, "B", 0, 200), + new HydraulicBoundaryLocation(0, "B", 0, 200) } }; var assessmentSectionStub = mockRepository.Stub(); @@ -241,15 +241,73 @@ IEnumerable expectedList = hydraulicBoundaryDatabase.Locations .Select(hbl => - new SelectableHydraulicBoundaryLocation(hbl, - calculation.InputParameters.Structure.Location)) + 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 @@ -643,6 +701,8 @@ private class SimpleStructure : StructureBase { public SimpleStructure() : base("Name", "Id", new Point2D(0, 0), 0.0) {} + + public SimpleStructure(Point2D location) : base("Name", "Id", location, 0.0) {} } private class SimpleStructureInput : StructuresInputBase Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs =================================================================== diff -u -r89774b7d8b41c979aa51de68ccd318352c4199aa -r8528bae438c3eecedaa7d4010cacc93846dce2b5 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 89774b7d8b41c979aa51de68ccd318352c4199aa) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 8528bae438c3eecedaa7d4010cacc93846dce2b5) @@ -234,7 +234,6 @@ new HydraulicBoundaryLocation(0, "B", 0, 4), } }; - mockRepository.ReplayAll(); var input = new GrassCoverErosionInwardsInput(); @@ -246,7 +245,8 @@ }; // Call - var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); + IEnumerable availableHydraulicBoundaryLocations = + properties.GetSelectableHydraulicBoundaryLocations(); // Assert IEnumerable expectedList = @@ -275,7 +275,6 @@ new HydraulicBoundaryLocation(0, "B", 0, 200) } }; - mockRepository.ReplayAll(); var input = new GrassCoverErosionInwardsInput() @@ -290,7 +289,8 @@ }; // Call - var availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); + IEnumerable availableHydraulicBoundaryLocations = + properties.GetSelectableHydraulicBoundaryLocations(); // Assert IEnumerable expectedList = @@ -305,6 +305,58 @@ } [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/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs =================================================================== diff -u -r89774b7d8b41c979aa51de68ccd318352c4199aa -r8528bae438c3eecedaa7d4010cacc93846dce2b5 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 89774b7d8b41c979aa51de68ccd318352c4199aa) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 8528bae438c3eecedaa7d4010cacc93846dce2b5) @@ -1301,10 +1301,12 @@ 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 = ValidSurfaceLine(0.0, 4.0) + SurfaceLine = surfaceLine }; // Call @@ -1313,13 +1315,74 @@ // Assert IEnumerable expectedList = - hydraulicBoundaryDatabase.Locations.Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, null)) + 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/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -r89774b7d8b41c979aa51de68ccd318352c4199aa -r8528bae438c3eecedaa7d4010cacc93846dce2b5 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 89774b7d8b41c979aa51de68ccd318352c4199aa) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 8528bae438c3eecedaa7d4010cacc93846dce2b5) @@ -339,6 +339,51 @@ } [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