Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Views/WaveConditionsInputView.cs =================================================================== diff -u -r5d517d1330fbcd67b88a1f23d01e006e1ad98c1c -rc9718aac47d13f790a2ec0cc7d51305361b90d77 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Views/WaveConditionsInputView.cs (.../WaveConditionsInputView.cs) (revision 5d517d1330fbcd67b88a1f23d01e006e1ad98c1c) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Views/WaveConditionsInputView.cs (.../WaveConditionsInputView.cs) (revision c9718aac47d13f790a2ec0cc7d51305361b90d77) @@ -22,6 +22,7 @@ using System; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Base.Data; using Core.Common.Util.Extensions; using Core.Components.Chart.Data; using Core.Components.Chart.Forms; @@ -38,6 +39,8 @@ /// public partial class WaveConditionsInputView : UserControl, IChartView { + private readonly Func getNormativeAssessmentLevelFunc; + private readonly Observer calculationObserver; private readonly Observer calculationInputObserver; private readonly Observer hydraulicBoundaryLocationObserver; @@ -59,17 +62,25 @@ /// Creates a new instance of . /// /// The style which should be applied to the . - /// Thrown when - /// is null. - public WaveConditionsInputView(IWaveConditionsInputViewStyle inputViewStyle) + /// for obtaining the normative assessment level. + /// Thrown when any input parameter is null. + public WaveConditionsInputView(IWaveConditionsInputViewStyle inputViewStyle, + Func getNormativeAssessmentLevelFunc) { if (inputViewStyle == null) { throw new ArgumentNullException(nameof(inputViewStyle)); } + if (getNormativeAssessmentLevelFunc == null) + { + throw new ArgumentNullException(nameof(getNormativeAssessmentLevelFunc)); + } + InitializeComponent(); + this.getNormativeAssessmentLevelFunc = getNormativeAssessmentLevelFunc; + calculationObserver = new Observer(UpdateChartTitle); calculationInputObserver = new Observer(UpdateCalculationInput); hydraulicBoundaryLocationObserver = new Observer(UpdateChartData); @@ -143,6 +154,7 @@ { components?.Dispose(); } + base.Dispose(disposing); } @@ -176,7 +188,7 @@ lowerBoundaryWaterLevelsChartData.Points = WaveConditionsChartDataPointsFactory.CreateLowerBoundaryWaterLevelsGeometryPoints(input); upperBoundaryWaterLevelsChartData.Points = WaveConditionsChartDataPointsFactory.CreateUpperBoundaryWaterLevelsGeometryPoints(input); designWaterLevelChartData.Points = WaveConditionsChartDataPointsFactory.CreateDesignWaterLevelGeometryPoints(input); - waterLevelsChartData.Lines = WaveConditionsChartDataPointsFactory.CreateWaterLevelsGeometryPoints(input, input.AssessmentLevel); + waterLevelsChartData.Lines = WaveConditionsChartDataPointsFactory.CreateWaterLevelsGeometryPoints(input, getNormativeAssessmentLevelFunc()); revetmentBaseChartData.Points = WaveConditionsChartDataPointsFactory.CreateRevetmentBaseGeometryPoints(input); revetmentChartData.Points = WaveConditionsChartDataPointsFactory.CreateRevetmentGeometryPoints(input); } Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Views/WaveConditionsInputViewTest.cs =================================================================== diff -u -rca50e203235730c6a88901c20588095704aeee84 -rc9718aac47d13f790a2ec0cc7d51305361b90d77 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Views/WaveConditionsInputViewTest.cs (.../WaveConditionsInputViewTest.cs) (revision ca50e203235730c6a88901c20588095704aeee84) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/Views/WaveConditionsInputViewTest.cs (.../WaveConditionsInputViewTest.cs) (revision c9718aac47d13f790a2ec0cc7d51305361b90d77) @@ -101,21 +101,32 @@ } [Test] - public void Constructor_WaveConditionsInputViewStyleNull_ThrowArgumentNullException() + public void Constructor_InputViewStyleNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new WaveConditionsInputView(null); + TestDelegate test = () => new WaveConditionsInputView(null, GetTestNormativeAssessmentLevel); // Assert var exception = Assert.Throws(test); Assert.AreEqual("inputViewStyle", exception.ParamName); } [Test] + public void Constructor_GetNormativeAssessmentLevelFuncNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("getNormativeAssessmentLevelFunc", exception.ParamName); + } + + [Test] public void Constructor_ExpectedValues() { // Call - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle())) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel)) { // Assert Assert.IsInstanceOf(view); @@ -130,7 +141,7 @@ public void Constructor_Always_AddEmptyChartControl() { // Call - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle())) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel)) { // Assert var chartControl = (IChartControl) view.Controls.Find("chartControl", true).First(); @@ -147,7 +158,7 @@ public void Data_IWaveConditionsCalculation_DataSet() { // Setup - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle())) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel)) { var calculation = new TestWaveConditionsCalculation(); @@ -163,7 +174,7 @@ public void Data_OtherThanWaveConditionsCalculation_DataNull() { // Setup - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle())) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel)) { var calculation = new object(); @@ -179,7 +190,7 @@ public void Data_SetToNull_ChartDataCleared() { // Setup - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle()) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel) { Data = new TestWaveConditionsCalculation() }) @@ -202,7 +213,7 @@ public void Data_EmptyCalculation_NoChartDataSet() { // Setup - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle())) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel)) { var calculation = new TestWaveConditionsCalculation(); @@ -220,7 +231,7 @@ // Setup const string calculationName = "Calculation name"; - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle())) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), () => (RoundedDouble) 6)) { var calculation = new TestWaveConditionsCalculation { @@ -236,8 +247,7 @@ LowerBoundaryRevetment = (RoundedDouble) 5, UpperBoundaryRevetment = (RoundedDouble) 8, LowerBoundaryWaterLevels = (RoundedDouble) 3, - UpperBoundaryWaterLevels = (RoundedDouble) 9, - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(6) + UpperBoundaryWaterLevels = (RoundedDouble) 9 } }; @@ -286,7 +296,7 @@ public void UpdateObserver_CalculationNameUpdated_ChartTitleUpdated() { // Setup - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle())) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel)) { const string initialName = "Initial name"; const string updatedName = "Updated name"; @@ -315,7 +325,7 @@ public void UpdateObserver_OtherCalculationNameUpdated_ChartTitleNotUpdated() { // Setup - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle())) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel)) { const string initialName = "Initial name"; const string updatedName = "Updated name"; @@ -366,12 +376,11 @@ LowerBoundaryRevetment = (RoundedDouble) 5, UpperBoundaryRevetment = (RoundedDouble) 8, LowerBoundaryWaterLevels = (RoundedDouble) 3, - UpperBoundaryWaterLevels = (RoundedDouble) 7, - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(6) + UpperBoundaryWaterLevels = (RoundedDouble) 7 } }; - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle()) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), () => (RoundedDouble) 6) { Data = calculation }) @@ -458,7 +467,7 @@ mocks.ReplayAll(); var calculation1 = new TestWaveConditionsCalculation(); - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle()) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel) { Data = calculation1 }) @@ -490,7 +499,6 @@ public void GivenViewWithInputData_WhenWaterLevelForCalculationUpdated_ThenUpdatedDataIsShownInChart(Func updateWaterLevelOnInput) { // Given - HydraulicBoundaryLocation testHydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); var profile = new TestForeshoreProfile(new[] { new Point2D(0.0, 0.0), @@ -505,12 +513,11 @@ LowerBoundaryRevetment = (RoundedDouble) 5, UpperBoundaryRevetment = (RoundedDouble) 8, LowerBoundaryWaterLevels = (RoundedDouble) 3, - UpperBoundaryWaterLevels = (RoundedDouble) 7, - HydraulicBoundaryLocation = testHydraulicBoundaryLocation + UpperBoundaryWaterLevels = (RoundedDouble) 7 } }; - using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle()) + using (var view = new WaveConditionsInputView(new TestWaveConditionsInputViewStyle(), GetTestNormativeAssessmentLevel) { Data = calculation }) @@ -703,5 +710,10 @@ { return ((pointY - lastForeshorePoint.Y) / 3) + lastForeshorePoint.X; } + + private static RoundedDouble GetTestNormativeAssessmentLevel() + { + return (RoundedDouble) 1.1; + } } } \ No newline at end of file