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(); }