Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs =================================================================== diff -u -r2b1ae71dbd5ecd83ad0fca2ea02c5d7d8219f7b9 -rf135e2b0ee4b6ff6eb52d57083243d48ba47cad7 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision 2b1ae71dbd5ecd83ad0fca2ea02c5d7d8219f7b9) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision f135e2b0ee4b6ff6eb52d57083243d48ba47cad7) @@ -36,8 +36,7 @@ /// public class WaveConditionsInput : Observable, ICalculationInput { - private readonly RoundedDouble designWaterLevelSubstraction; - private readonly List waterLevels; + private const double designWaterLevelSubstraction = 0.01; private DikeProfile dikeProfile; private HydraulicBoundaryLocation hydraulicBoundaryLocation; @@ -47,9 +46,6 @@ private RoundedDouble upperWaterLevel; private RoundedDouble stepSize; - private RoundedDouble upperBoundary; - private RoundedDouble lowerBoundary; - /// /// Creates a new instance of . /// @@ -61,13 +57,6 @@ upperWaterLevel = new RoundedDouble(2); stepSize = new RoundedDouble(1); - upperBoundary = new RoundedDouble(2); - lowerBoundary = new RoundedDouble(2); - - designWaterLevelSubstraction = new RoundedDouble(2, 0.01); - - waterLevels = new List(); - UpdateDikeProfileParameters(); } @@ -143,7 +132,6 @@ set { upperRevetmentLevel = value.ToPrecision(upperRevetmentLevel.NumberOfDecimalPlaces); - DetermineBoundaries(); } } @@ -159,7 +147,6 @@ set { lowerRevetmentLevel = value.ToPrecision(lowerRevetmentLevel.NumberOfDecimalPlaces); - DetermineBoundaries(); } } @@ -175,7 +162,6 @@ set { lowerWaterLevel = value.ToPrecision(lowerWaterLevel.NumberOfDecimalPlaces); - DetermineBoundaries(); } } @@ -191,7 +177,6 @@ set { stepSize = value.ToPrecision(stepSize.NumberOfDecimalPlaces); - DetermineWaterLevels(); } } @@ -207,94 +192,60 @@ private set { upperWaterLevel = value.ToPrecision(upperWaterLevel.NumberOfDecimalPlaces); - DetermineBoundaries(); } } /// - /// Gets the upper boundary of the waterlevels that should be calculated.. - /// - public RoundedDouble UpperBoundary - { - get - { - return upperBoundary; - } - private set - { - upperBoundary = value.ToPrecision(upperBoundary.NumberOfDecimalPlaces); - } - } - - /// - /// Gets the lower boundary of the waterlevels that should be calculated.. - /// - public RoundedDouble LowerBoundary - { - get - { - return lowerBoundary; - } - private set - { - lowerBoundary = value.ToPrecision(lowerBoundary.NumberOfDecimalPlaces); - } - } - - /// /// Gets the water levels to calculate for. /// public IEnumerable WaterLevels { get { - return waterLevels; + return DetermineWaterLevels(); } } private void UpdateUpperWaterLevel() { if (hydraulicBoundaryLocation != null && !double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel)) { - UpperWaterLevel = hydraulicBoundaryLocation.DesignWaterLevel - designWaterLevelSubstraction; + UpperWaterLevel = (RoundedDouble) (hydraulicBoundaryLocation.DesignWaterLevel - designWaterLevelSubstraction); } else { UpperWaterLevel = (RoundedDouble) 0; } } - private void DetermineBoundaries() + private IEnumerable DetermineWaterLevels() { - UpperBoundary = UpperWaterLevel < UpperRevetmentLevel ? UpperWaterLevel : UpperRevetmentLevel; - LowerBoundary = LowerWaterLevel > LowerRevetmentLevel ? LowerWaterLevel : LowerRevetmentLevel; + var upperBoundary = UpperWaterLevel < UpperRevetmentLevel ? UpperWaterLevel : UpperRevetmentLevel; + var lowerBoundary = LowerWaterLevel > LowerRevetmentLevel ? LowerWaterLevel : LowerRevetmentLevel; - DetermineWaterLevels(); - } + var waterLevels = new List(); - private void DetermineWaterLevels() - { - waterLevels.Clear(); - - if (double.IsNaN(UpperBoundary) || - double.IsNaN(LowerBoundary) || - Math.Abs(LowerBoundary - UpperBoundary) < 1e-6 || + if (double.IsNaN(upperBoundary) || + double.IsNaN(lowerBoundary) || + Math.Abs(lowerBoundary - upperBoundary) < 1e-6 || Math.Abs(StepSize) < 1e-6) { - return; + return waterLevels; } - waterLevels.Add(LowerBoundary); + waterLevels.Add(lowerBoundary); - RoundedDouble currentWaterLevel = new RoundedDouble(2, Math.Floor(lowerBoundary / stepSize) * stepSize + stepSize); + RoundedDouble currentWaterLevel = new RoundedDouble(2, Math.Floor(lowerBoundary/stepSize)*stepSize + stepSize); - while (currentWaterLevel < UpperBoundary) + while (currentWaterLevel < upperBoundary) { waterLevels.Add(currentWaterLevel); currentWaterLevel = (currentWaterLevel + stepSize).ToPrecision(currentWaterLevel.NumberOfDecimalPlaces); } waterLevels.Add(upperBoundary); + + return waterLevels; } private void UpdateDikeProfileParameters() Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsOutput.cs =================================================================== diff -u -rda4575000cf1c3510b9ff860c0a97e60a95f7908 -rf135e2b0ee4b6ff6eb52d57083243d48ba47cad7 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsOutput.cs (.../WaveConditionsOutput.cs) (revision da4575000cf1c3510b9ff860c0a97e60a95f7908) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsOutput.cs (.../WaveConditionsOutput.cs) (revision f135e2b0ee4b6ff6eb52d57083243d48ba47cad7) @@ -60,7 +60,7 @@ public double WavePeriod { get; private set; } /// - /// Gets the calculated wave angle. + /// Gets the calculated wave orientation. /// public double WaveOrientation { get; private set; } } Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs =================================================================== diff -u -r2b1ae71dbd5ecd83ad0fca2ea02c5d7d8219f7b9 -rf135e2b0ee4b6ff6eb52d57083243d48ba47cad7 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision 2b1ae71dbd5ecd83ad0fca2ea02c5d7d8219f7b9) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision f135e2b0ee4b6ff6eb52d57083243d48ba47cad7) @@ -85,8 +85,6 @@ Assert.AreEqual(new RoundedDouble(2), input.LowerWaterLevel); Assert.AreEqual(new RoundedDouble(2), input.UpperWaterLevel); Assert.AreEqual(new RoundedDouble(1), input.StepSize); - Assert.AreEqual(new RoundedDouble(2), input.LowerBoundary); - Assert.AreEqual(new RoundedDouble(2), input.UpperBoundary); CollectionAssert.IsEmpty(input.WaterLevels); } @@ -262,22 +260,13 @@ } [Test] - [TestCase(true, 6.34, 8.19, 8.18, 6.34)] - [TestCase(true, 8.63, 6.77, 6.76, 6.76)] - [TestCase(false, double.NaN, 7.32, 7.31, 0)] - public void HydraulicBoundaryLocation_SetNewValue_UpperWaterLevelUpdatedAndBoundariesSyncedAccordingly(bool upperRevetmentLevelSet, - double upperRevetmentLevel, - double designWaterLevel, - double expectedUpperWaterLevel, - double expectedUpperBoundary) + public void HydraulicBoundaryLocation_SetNewValue_UpperWaterLevelUpdated() { // Setup var input = new WaveConditionsInput(); - if (upperRevetmentLevelSet) - { - input.UpperRevetmentLevel = (RoundedDouble) upperRevetmentLevel; - } + var designWaterLevel = 8.19; + var expectedWaterLevel = 8.18; var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) { @@ -288,8 +277,7 @@ input.HydraulicBoundaryLocation = hydraulicBoundaryLocation; // Assert - Assert.AreEqual(expectedUpperWaterLevel, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy()); - Assert.AreEqual(expectedUpperBoundary, input.UpperBoundary, input.UpperBoundary.GetAccuracy()); + Assert.AreEqual(expectedWaterLevel, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy()); } [Test] @@ -351,81 +339,6 @@ } [Test] - [TestCase(true, 7.65, 5.39, 5.39)] - [TestCase(true, 7.65, 8.34, 7.64)] - [TestCase(false, double.NaN, 5.39, 0)] - public void UpperRevetmentLevel_SetNewValue_BoundariesSyncedAccordingly(bool hydraulicBoundaryLocationSet, - double designWaterLevel, - double upperRevetmentLevel, - double expectedUpperBoundary) - { - // Setup - var input = new WaveConditionsInput(); - - if (hydraulicBoundaryLocationSet) - { - input.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) - { - DesignWaterLevel = (RoundedDouble) designWaterLevel - }; - } - - // Call - input.UpperRevetmentLevel = (RoundedDouble) upperRevetmentLevel; - - // Assert - Assert.AreEqual(expectedUpperBoundary, input.UpperBoundary, input.UpperBoundary.GetAccuracy()); - } - - [Test] - [TestCase(true, -2.31, -1.53, -1.53)] - [TestCase(true, -1.56, -3.29, -1.56)] - [TestCase(false, double.NaN, -1.29, 0)] - public void LowerRevetmentLevel_SetNewValue_BoundariesSyncedAccordingly(bool lowerWaterLevelSet, - double lowerWaterLevel, - double lowerRevetmentLevel, - double expectedLowerBoundary) - { - // Setup - var input = new WaveConditionsInput(); - - if (lowerWaterLevelSet) - { - input.LowerWaterLevel = (RoundedDouble) lowerWaterLevel; - } - - // Call - input.LowerRevetmentLevel = (RoundedDouble) lowerRevetmentLevel; - - // Assert - Assert.AreEqual(expectedLowerBoundary, input.LowerBoundary, input.LowerBoundary.GetAccuracy()); - } - - [Test] - [TestCase(true, -2.31, -1.53, -1.53)] - [TestCase(true, -1.56, -3.29, -1.56)] - [TestCase(false, double.NaN, -1.29, 0)] - public void LowerWaterLevel_SetNewValue_BoundariesSyncedAccordingly(bool lowerRevetmentLevelSet, - double lowerRevetmentLevel, - double lowerWaterLevel, - double expectedLowerBoundary) - { - // Setup - var input = new WaveConditionsInput(); - - if (lowerRevetmentLevelSet) - { - input.LowerRevetmentLevel = (RoundedDouble) lowerRevetmentLevel; - } - - // Call - input.LowerWaterLevel = (RoundedDouble) lowerWaterLevel; - - // Assert - Assert.AreEqual(expectedLowerBoundary, input.LowerBoundary, input.LowerBoundary.GetAccuracy()); - } - - [Test] public void StepSize_SetNewValueBoundariesNotDefined_NoWaterLevelCalculations() { // Setup Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/Ringtoets.StabilityStoneCover.Data.csproj =================================================================== diff -u -rfe88fe6361cce143bfcfab2886bcc3ad0b81894b -rf135e2b0ee4b6ff6eb52d57083243d48ba47cad7 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/Ringtoets.StabilityStoneCover.Data.csproj (.../Ringtoets.StabilityStoneCover.Data.csproj) (revision fe88fe6361cce143bfcfab2886bcc3ad0b81894b) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/Ringtoets.StabilityStoneCover.Data.csproj (.../Ringtoets.StabilityStoneCover.Data.csproj) (revision f135e2b0ee4b6ff6eb52d57083243d48ba47cad7) @@ -48,6 +48,7 @@ + Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverWaveConditionsCalculation.cs =================================================================== diff -u -rfe88fe6361cce143bfcfab2886bcc3ad0b81894b -rf135e2b0ee4b6ff6eb52d57083243d48ba47cad7 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverWaveConditionsCalculation.cs (.../StabilityStoneCoverWaveConditionsCalculation.cs) (revision fe88fe6361cce143bfcfab2886bcc3ad0b81894b) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverWaveConditionsCalculation.cs (.../StabilityStoneCoverWaveConditionsCalculation.cs) (revision f135e2b0ee4b6ff6eb52d57083243d48ba47cad7) @@ -48,7 +48,7 @@ /// /// Gets or sets the output which contains the results of a wave conditions calculation. /// - public ObservableList Output { get; set; } + public StabilityStoneCoverWaveConditionsOutput Output { get; set; } public string Name { get; set; } @@ -74,8 +74,7 @@ public ICalculationOutput GetObservableOutput() { - return null; -// return Output; + return Output; } } } \ No newline at end of file Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverWaveConditionsOutput.cs =================================================================== diff -u --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverWaveConditionsOutput.cs (revision 0) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverWaveConditionsOutput.cs (revision f135e2b0ee4b6ff6eb52d57083243d48ba47cad7) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.Base; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Revetment.Data; + +namespace Ringtoets.StabilityStoneCover.Data +{ + /// + /// The result of the stability stone cover wave conditions assessment. + /// + public class StabilityStoneCoverWaveConditionsOutput : Observable, ICalculationOutput + { + /// + /// Creates a new instance of . + /// + /// The wave conditions output for columns. + /// The wave conditions output for blocks. + /// Thrown when + /// or is null. + public StabilityStoneCoverWaveConditionsOutput(IEnumerable columnsOutput, IEnumerable blocksOutput) + { + if (columnsOutput == null) + { + throw new ArgumentNullException("columnsOutput"); + } + + if (blocksOutput == null) + { + throw new ArgumentNullException("blocksOutput"); + } + + ColumnsOutput = columnsOutput; + BlocksOutput = blocksOutput; + } + + /// + /// Gets the wave conditions output for blocks. + /// + public IEnumerable BlocksOutput { get; private set; } + + /// + /// Gets the wave conditions output for columns. + /// + public IEnumerable ColumnsOutput { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/Ringtoets.StabilityStoneCover.Data.Test.csproj =================================================================== diff -u -rfe88fe6361cce143bfcfab2886bcc3ad0b81894b -rf135e2b0ee4b6ff6eb52d57083243d48ba47cad7 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/Ringtoets.StabilityStoneCover.Data.Test.csproj (.../Ringtoets.StabilityStoneCover.Data.Test.csproj) (revision fe88fe6361cce143bfcfab2886bcc3ad0b81894b) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/Ringtoets.StabilityStoneCover.Data.Test.csproj (.../Ringtoets.StabilityStoneCover.Data.Test.csproj) (revision f135e2b0ee4b6ff6eb52d57083243d48ba47cad7) @@ -52,6 +52,7 @@ + Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverWaveConditionsCalculationTest.cs =================================================================== diff -u -rfe88fe6361cce143bfcfab2886bcc3ad0b81894b -rf135e2b0ee4b6ff6eb52d57083243d48ba47cad7 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverWaveConditionsCalculationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationTest.cs) (revision fe88fe6361cce143bfcfab2886bcc3ad0b81894b) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverWaveConditionsCalculationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationTest.cs) (revision f135e2b0ee4b6ff6eb52d57083243d48ba47cad7) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Linq; using Core.Common.Base; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; @@ -54,9 +55,12 @@ // Setup var calculation = new StabilityStoneCoverWaveConditionsCalculation { - Output = new ObservableList() + Output = new StabilityStoneCoverWaveConditionsOutput(Enumerable.Empty(), Enumerable.Empty()) }; + // Precondition + Assert.IsNotNull(calculation.Output); + // Call calculation.ClearOutput(); @@ -73,8 +77,11 @@ Output = null }; - // Call & Assert - Assert.IsFalse(calculation.HasOutput); + // Call + bool hasOutput = calculation.HasOutput; + + // Assert + Assert.IsFalse(hasOutput); } [Test] @@ -83,11 +90,14 @@ // Setup var calculation = new StabilityStoneCoverWaveConditionsCalculation { - Output = new ObservableList() + Output = new StabilityStoneCoverWaveConditionsOutput(Enumerable.Empty(), Enumerable.Empty()) }; - // Call & Assert - Assert.IsTrue(calculation.HasOutput); + // Call + bool hasOutput = calculation.HasOutput; + + // Assert + Assert.IsTrue(hasOutput); } [Test] Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverWaveConditionsOutputTest.cs =================================================================== diff -u --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverWaveConditionsOutputTest.cs (revision 0) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverWaveConditionsOutputTest.cs (revision f135e2b0ee4b6ff6eb52d57083243d48ba47cad7) @@ -0,0 +1,78 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Linq; +using NUnit.Framework; +using Ringtoets.Revetment.Data; + +namespace Ringtoets.StabilityStoneCover.Data.Test +{ + [TestFixture] + public class StabilityStoneCoverWaveConditionsOutputTest + { + [Test] + public void Constructor_ColumnsOutputNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new StabilityStoneCoverWaveConditionsOutput(null, Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("columnsOutput", exception.ParamName); + } + + [Test] + public void Constructor_BlocksOutputNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new StabilityStoneCoverWaveConditionsOutput(Enumerable.Empty(), null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("blocksOutput", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var columnsOutput = new[] + { + new WaveConditionsOutput(1, 0, 3, 5), + new WaveConditionsOutput(8, 2, 6, 1) + }; + + var blocksOutput = new[] + { + new WaveConditionsOutput(6, 2, 9, 4), + new WaveConditionsOutput(4, 1, 7, 3) + }; + + // Call + var output = new StabilityStoneCoverWaveConditionsOutput(columnsOutput, blocksOutput); + + // Assert + Assert.AreSame(columnsOutput, output.ColumnsOutput); + Assert.AreSame(blocksOutput, output.BlocksOutput); + } + } +} \ No newline at end of file