Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PresentationObjects/WaveConditionsInputContextTest.cs =================================================================== diff -u -r1ab13c60f0a6168b2e959bc213d229d2c77af3b6 -r510eedcefbae9aff40e2d215573588f8e40761f7 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PresentationObjects/WaveConditionsInputContextTest.cs (.../WaveConditionsInputContextTest.cs) (revision 1ab13c60f0a6168b2e959bc213d229d2c77af3b6) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PresentationObjects/WaveConditionsInputContextTest.cs (.../WaveConditionsInputContextTest.cs) (revision 510eedcefbae9aff40e2d215573588f8e40761f7) @@ -27,7 +27,6 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; -using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Data.TestUtil; using Ringtoets.Revetment.Forms.PresentationObjects; @@ -106,8 +105,6 @@ IAssessmentSection assessmentSection) : base(wrappedData, calculation, assessmentSection) {} - public override IEnumerable HydraulicBoundaryLocations { get; } - public override IEnumerable ForeshoreProfiles { get; } } } Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -r1fd2033b78aa540d01635bcf993080e5fe2437bd -r510eedcefbae9aff40e2d215573588f8e40761f7 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 1fd2033b78aa540d01635bcf993080e5fe2437bd) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 510eedcefbae9aff40e2d215573588f8e40761f7) @@ -68,51 +68,45 @@ private const int foreshoreGeometryPropertyIndex = 13; private const int revetmentTypePropertyIndex = 14; - private MockRepository mockRepository; - private IAssessmentSection assessmentSection; - private IObservablePropertyChangeHandler handler; - - [SetUp] - public void SetUp() - { - mockRepository = new MockRepository(); - assessmentSection = mockRepository.Stub(); - handler = mockRepository.Stub(); - mockRepository.ReplayAll(); - } - - [TearDown] - public void TearDown() - { - mockRepository.VerifyAll(); - } - [Test] public void Constructor_DataNull_ThrowsArgumentNullException() { + // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + // Call TestDelegate test = () => new TestWaveConditionsInputContextProperties(null, GetTestNormativeAssessmentLevel, handler); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("context", paramName); + mocks.VerifyAll(); } [Test] public void Constructor_GetNormativeAssessmentLevelFuncNull_ThrowsArgumentNullException() { // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var assessmentSection = new AssessmentSectionStub(); + var context = new TestWaveConditionsInputContext( new WaveConditionsInput(), Enumerable.Empty(), - Enumerable.Empty()); + assessmentSection); // Call TestDelegate test = () => new TestWaveConditionsInputContextProperties(context, null, handler); // Assert var exception = Assert.Throws(test); Assert.AreEqual("getNormativeAssessmentLevelFunc", exception.ParamName); + mocks.VerifyAll(); } [Test] @@ -122,7 +116,7 @@ var context = new TestWaveConditionsInputContext( new WaveConditionsInput(), Enumerable.Empty(), - Enumerable.Empty()); + new AssessmentSectionStub()); // Call TestDelegate test = () => new TestWaveConditionsInputContextProperties(context, GetTestNormativeAssessmentLevel, null); @@ -136,6 +130,12 @@ public void Constructor_WithValidData_ExpectedValues() { // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var assessmentSection = new AssessmentSectionStub(); + var random = new Random(21); RoundedDouble assessmentLevel = random.NextRoundedDouble(); RoundedDouble lowerBoundaryRevetment = random.NextRoundedDouble(); @@ -171,7 +171,7 @@ LowerBoundaryWaterLevels = lowerBoundaryWaterLevels, StepSize = stepSize }; - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); + var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], assessmentSection); // Call var properties = new TestWaveConditionsInputContextProperties(inputContext, () => assessmentLevel, handler); @@ -206,13 +206,20 @@ Assert.AreEqual(BreakWaterType.Dam, properties.BreakWater.BreakWaterType); Assert.AreEqual(damHeight, properties.BreakWater.BreakWaterHeight.Value, properties.BreakWater.BreakWaterHeight.GetAccuracy()); CollectionAssert.IsEmpty(properties.ForeshoreGeometry.Coordinates); + mocks.VerifyAll(); } [Test] public void Constructor_Always_PropertiesHaveExpectedAttributesValues( [Values(true, false)] bool withForeshoreProfile) { // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var assessmentSection = new AssessmentSectionStub(); + var input = new WaveConditionsInput(); var foreshoreProfile = new TestForeshoreProfile(); @@ -224,7 +231,7 @@ var inputContext = new TestWaveConditionsInputContext(input, new[] { foreshoreProfile - }, new HydraulicBoundaryLocation[0]); + }, assessmentSection); // Call var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); @@ -344,12 +351,19 @@ Assert.AreEqual(schematizationCategory, revetmentTypeProperty.Category); Assert.AreEqual("Type bekleding", revetmentTypeProperty.DisplayName); Assert.AreEqual("Het type van de bekleding waarvoor berekend wordt.", revetmentTypeProperty.Description); + mocks.VerifyAll(); } [Test] public void WaterLevels_WithValidData_ExpectedValues() { // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var assessmentSection = new AssessmentSectionStub(); + var assessmentLevel = (RoundedDouble) 5.99; var lowerBoundaryRevetment = (RoundedDouble) 3.58; var lowerBoundaryWaterLevels = (RoundedDouble) 3.40; @@ -365,14 +379,15 @@ LowerBoundaryWaterLevels = lowerBoundaryWaterLevels, StepSize = stepSize }; - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); + var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], assessmentSection); // Call var properties = new TestWaveConditionsInputContextProperties(inputContext, () => assessmentLevel, handler); // Assert Assert.IsNotEmpty(properties.WaterLevels); CollectionAssert.AreEqual(input.GetWaterLevels(assessmentLevel), properties.WaterLevels); + mocks.VerifyAll(); } [Test] @@ -459,8 +474,15 @@ [Test] public void SelectedHydraulicBoundaryLocation_InputNoLocation_ReturnsNull() { + // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var assessmentSection = new AssessmentSectionStub(); + var input = new WaveConditionsInput(); - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); + var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], assessmentSection); var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); @@ -472,23 +494,30 @@ // Assert Assert.DoesNotThrow(call); Assert.IsNull(selectedHydraulicBoundaryLocation); + mocks.VerifyAll(); } [Test] public void GetSelectableHydraulicBoundaryLocations_InputWithLocationsForeshoreProfile_CalculatesDistanceWithCorrectReferencePoint() { // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 200643.312, 503347.25); - var locations = new List + + var assessmentSection = new AssessmentSectionStub(); + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { hydraulicBoundaryLocation - }; + }); var input = new WaveConditionsInput { ForeshoreProfile = new TestForeshoreProfile(new Point2D(200620.173572981, 503401.652985217)) }; - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); + var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], assessmentSection); var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); @@ -507,19 +536,31 @@ SelectableHydraulicBoundaryLocation hydraulicBoundaryLocationItem = availableHydraulicBoundaryLocations.ToArray()[0]; RoundedDouble itemDistance = hydraulicBoundaryLocationItem.Distance; Assert.AreEqual(distanceToForeshoreProfileReferencePoint, itemDistance, itemDistance.GetAccuracy()); + mocks.VerifyAll(); } [Test] public void SelectedHydraulicBoundaryLocation_InputWithLocationsForeshoreProfile_CalculatesDistanceWithCorrectReferencePoint() { // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 200643.312, 503347.25); var input = new WaveConditionsInput { HydraulicBoundaryLocation = hydraulicBoundaryLocation, ForeshoreProfile = new TestForeshoreProfile(new Point2D(200620.173572981, 503401.652985217)) }; - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); + + var assessmentSection = new AssessmentSectionStub(); + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }); + + var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], assessmentSection); var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // Call @@ -535,25 +576,33 @@ RoundedDouble selectedLocationDistance = selectedHydraulicBoundaryLocation.Distance; Assert.AreEqual(distanceToForeshoreProfileReferencePoint, selectedLocationDistance, selectedLocationDistance.GetAccuracy()); + mocks.VerifyAll(); } [Test] public void GivenPropertiesWithForeshoreProfileAndLocations_WhenSelectingLocation_ThenSelectedLocationDistanceSameAsLocationItem() { // Given + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 200643.312, 503347.25); - var locations = new List - { - hydraulicBoundaryLocation - }; var input = new WaveConditionsInput { HydraulicBoundaryLocation = hydraulicBoundaryLocation, ForeshoreProfile = new TestForeshoreProfile(new Point2D(200620.173572981, 503401.652985217)) }; - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); + var assessmentSection = new AssessmentSectionStub(); + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }); + + var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], assessmentSection); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // When @@ -565,12 +614,17 @@ SelectableHydraulicBoundaryLocation hydraulicBoundaryLocationItem = availableHydraulicBoundaryLocations.ToArray()[0]; Assert.AreEqual(selectedLocation.Distance, hydraulicBoundaryLocationItem.Distance, hydraulicBoundaryLocationItem.Distance.GetAccuracy()); + mocks.VerifyAll(); } [Test] public void GetSelectableHydraulicBoundaryLocations_InputWithLocationsNoReferencePoint_ReturnsLocationsSortedById() { // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + var locations = new List { new HydraulicBoundaryLocation(1, "A", 0, 1), @@ -579,8 +633,11 @@ new HydraulicBoundaryLocation(2, "B", 0, 4) }; + var assessmentSection = new AssessmentSectionStub(); + assessmentSection.SetHydraulicBoundaryLocationCalculations(locations); + var input = new WaveConditionsInput(); - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); + var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], assessmentSection); var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); @@ -592,12 +649,17 @@ locations.Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, null)) .OrderBy(hbl => hbl.HydraulicBoundaryLocation.Id); CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); + mocks.VerifyAll(); } [Test] public void GetSelectableHydraulicBoundaryLocations_InputWithLocationsAndReferencePoint_ReturnsLocationsSortedByDistanceThenById() { // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + var locations = new List { new HydraulicBoundaryLocation(1, "A", 0, 10), @@ -612,8 +674,12 @@ { ForeshoreProfile = new TestForeshoreProfile() }; - var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); + var assessmentSection = new AssessmentSectionStub(); + assessmentSection.SetHydraulicBoundaryLocationCalculations(locations); + + var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], assessmentSection); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // Call @@ -625,6 +691,7 @@ .OrderBy(hbl => hbl.Distance) .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Name); CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); + mocks.VerifyAll(); } [Test] @@ -641,6 +708,9 @@ new HydraulicBoundaryLocation(2, "B", 0, 200) }; + var assessmentSection = new AssessmentSectionStub(); + assessmentSection.SetHydraulicBoundaryLocationCalculations(locations); + var input = new WaveConditionsInput { ForeshoreProfile = new TestForeshoreProfile() @@ -677,34 +747,44 @@ public void GetAvailableForeshoreProfiles_InputWithLocations_ReturnsLocations() { // Setup - var locations = new List + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var assessmentSection = new AssessmentSectionStub(); + + var foreshoreProfiles = new List { new TestForeshoreProfile() }; var input = new WaveConditionsInput(); - var inputContext = new TestWaveConditionsInputContext(input, locations, new HydraulicBoundaryLocation[0]); + var inputContext = new TestWaveConditionsInputContext(input, foreshoreProfiles, assessmentSection); var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // Call IEnumerable availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles(); // Assert - Assert.AreSame(locations, availableForeshoreProfiles); + Assert.AreSame(foreshoreProfiles, availableForeshoreProfiles); + mocks.VerifyAll(); } - private void SetPropertyAndVerifyNotificationsAndOutputForCalculation(Action setProperty) + private static void SetPropertyAndVerifyNotificationsAndOutputForCalculation(Action setProperty) { // Setup var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); var observable = mocks.StrictMock(); observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); var calculation = new TestWaveConditionsCalculation(); - var input = new WaveConditionsInput(); - input.ForeshoreProfile = new TestForeshoreProfile(); + var input = new WaveConditionsInput + { + ForeshoreProfile = new TestForeshoreProfile() + }; var context = new TestWaveConditionsInputContext(input, calculation, Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.TestUtil/TestWaveConditionsInputContext.cs =================================================================== diff -u -ra1869f8c64dd48c6da8ec010dfd43ddb8effedfa -r510eedcefbae9aff40e2d215573588f8e40761f7 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.TestUtil/TestWaveConditionsInputContext.cs (.../TestWaveConditionsInputContext.cs) (revision a1869f8c64dd48c6da8ec010dfd43ddb8effedfa) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.TestUtil/TestWaveConditionsInputContext.cs (.../TestWaveConditionsInputContext.cs) (revision 510eedcefbae9aff40e2d215573588f8e40761f7) @@ -44,22 +44,22 @@ public TestWaveConditionsInputContext(WaveConditionsInput wrappedData) : this(wrappedData, new ForeshoreProfile[0], - new HydraulicBoundaryLocation[0]) {} + new AssessmentSectionStub()) {} /// /// Creates a new . /// /// The wrapped . /// The foreshore profiles. - /// The hydraulic boundary locations. + /// The assessment section. public TestWaveConditionsInputContext(WaveConditionsInput wrappedData, IEnumerable foreshoreProfiles, - IEnumerable locations) + IAssessmentSection assesmentSection) : this(wrappedData, new TestWaveConditionsCalculation(), - new AssessmentSectionStub(), + assesmentSection, foreshoreProfiles, - locations) {} + assesmentSection.HydraulicBoundaryDatabase.Locations) {} /// /// Creates a new .