Index: Ringtoets/Common/src/Ringtoets.Common.Data/Hydraulics/HydraulicBoundaryLocationOutput.cs =================================================================== diff -u -ra05010135dfc0fae86946bddd4f8891a07206938 -r7b361b577c778a137cbdb78603822412e189b93e --- Ringtoets/Common/src/Ringtoets.Common.Data/Hydraulics/HydraulicBoundaryLocationOutput.cs (.../HydraulicBoundaryLocationOutput.cs) (revision a05010135dfc0fae86946bddd4f8891a07206938) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Hydraulics/HydraulicBoundaryLocationOutput.cs (.../HydraulicBoundaryLocationOutput.cs) (revision 7b361b577c778a137cbdb78603822412e189b93e) @@ -34,38 +34,20 @@ /// /// Creates a new instance of . /// - /// The calculation result. - /// The norm used during the calculation. - /// The reliability index used during the calculation. - /// the calculated probability. - /// The calculated reliability. - /// The convergence status of the calculation. - /// Thrown when - /// or falls outside the [0.0, 1.0] range and is not . - public HydraulicBoundaryLocationOutput(double result, double targetProbability, double targetReliability, - double calculatedProbability, double calculatedReliability, - CalculationConvergence calculationConvergence) - : this(result, targetProbability, targetReliability, calculatedProbability, calculatedReliability, calculationConvergence, null) {} - - /// - /// Creates a new instance of . - /// /// The calculation result. /// The norm used during the calculation. /// The reliability index used during the calculation. /// the calculated probability. /// The calculated reliability. /// The convergence status of the calculation. - /// The general illustration point result. /// Thrown when /// or falls outside the [0.0, 1.0] range and is not . public HydraulicBoundaryLocationOutput(double result, double targetProbability, double targetReliability, double calculatedProbability, double calculatedReliability, - CalculationConvergence calculationConvergence, - GeneralResult generalResult) + CalculationConvergence calculationConvergence) { ProbabilityHelper.ValidateProbability(targetProbability, nameof(targetProbability), true); ProbabilityHelper.ValidateProbability(calculatedProbability, nameof(calculatedProbability), true); @@ -77,7 +59,6 @@ CalculatedProbability = calculatedProbability; CalculatedReliability = new RoundedDouble(5, calculatedReliability); CalculationConvergence = calculationConvergence; - GeneralResult = generalResult; } /// @@ -118,7 +99,7 @@ /// /// Gets the general illustration points result. /// - public GeneralResult GeneralResult { get; } + public GeneralResult GeneralResult { get; private set; } /// /// Gets if the output contains illustration points. @@ -130,5 +111,20 @@ return GeneralResult != null; } } + + /// + /// Sets the general result of the illustration points. + /// + /// + /// Thrown when + /// is null. + public void SetIllustrationPoints(GeneralResult generalResult) + { + if (generalResult == null) + { + throw new ArgumentNullException(nameof(generalResult)); + } + GeneralResult = generalResult; + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Hydraulics/HydraulicBoundaryLocationOutputTest.cs =================================================================== diff -u -rf1e6b4ad5dddc6e771288f17a0b619d6dd23ec07 -r7b361b577c778a137cbdb78603822412e189b93e --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Hydraulics/HydraulicBoundaryLocationOutputTest.cs (.../HydraulicBoundaryLocationOutputTest.cs) (revision f1e6b4ad5dddc6e771288f17a0b619d6dd23ec07) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Hydraulics/HydraulicBoundaryLocationOutputTest.cs (.../HydraulicBoundaryLocationOutputTest.cs) (revision 7b361b577c778a137cbdb78603822412e189b93e) @@ -20,12 +20,11 @@ // All rights reserved. using System; -using System.Linq; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; -using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; namespace Ringtoets.Common.Data.Test.Hydraulics { @@ -47,7 +46,8 @@ var convergence = random.NextEnumValue(); // Call - TestDelegate call = () => new HydraulicBoundaryLocationOutput(result, targetProbability, + TestDelegate call = () => new HydraulicBoundaryLocationOutput(result, + targetProbability, targetReliability, calculatedProbability, calculatedReliability, @@ -74,7 +74,8 @@ var convergence = random.NextEnumValue(); // Call - TestDelegate call = () => new HydraulicBoundaryLocationOutput(result, targetProbability, + TestDelegate call = () => new HydraulicBoundaryLocationOutput(result, + targetProbability, targetReliability, calculatedProbability, calculatedReliability, @@ -87,7 +88,7 @@ } [Test] - public void Constructor_ValidInputWithoutGeneralResult_ExpectedProperties() + public void Constructor_ValidInput_ExpectedProperties() { // Setup var random = new Random(32); @@ -99,7 +100,8 @@ var convergence = random.NextEnumValue(); // Call - var output = new HydraulicBoundaryLocationOutput(result, targetProbability, + var output = new HydraulicBoundaryLocationOutput(result, + targetProbability, targetReliability, calculatedProbability, calculatedReliability, @@ -117,72 +119,37 @@ } [Test] - public void Constructor_ValidInputWithGeneralResult_ExpectedProperties() + public void SetIllustrationPoints_GeneralResultNull_ThrowsArgumentNullException() { // Setup var random = new Random(32); double result = random.NextDouble(); - double targetProbability = random.NextDouble(); - double targetReliability = random.NextDouble(); - double calculatedProbability = random.NextDouble(); - double calculatedReliability = random.NextDouble(); - var convergence = random.NextEnumValue(); + var output = new TestHydraulicBoundaryLocationOutput(result); - var windDirection = new WindDirection("SSE", random.NextDouble()); - double beta = random.NextDouble(); - var generalResult = new GeneralResult(beta, - windDirection, - Enumerable.Empty(), - Enumerable.Empty()); - // Call - var output = new HydraulicBoundaryLocationOutput(result, targetProbability, - targetReliability, - calculatedProbability, - calculatedReliability, - convergence, - generalResult); + TestDelegate call = () => output.SetIllustrationPoints(null); // Assert - Assert.AreEqual(result, output.Result, output.Result.GetAccuracy()); - Assert.AreEqual(targetProbability, output.TargetProbability); - Assert.AreEqual(targetReliability, output.TargetReliability, output.TargetReliability.GetAccuracy()); - Assert.AreEqual(calculatedProbability, output.CalculatedProbability); - Assert.AreEqual(calculatedReliability, output.CalculatedReliability, output.CalculatedReliability.GetAccuracy()); - Assert.AreEqual(convergence, output.CalculationConvergence); - Assert.AreSame(generalResult, output.GeneralResult); - Assert.IsTrue(output.HasIllustrationPoints); + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("generalResult", paramName); } [Test] - public void Constructor_ValidInputWithGeneralResultNull_ExpectedProperties() + public void SetIllustrationPoints_ValidGeneralResult_SetsExpectedProperties() { // Setup var random = new Random(32); double result = random.NextDouble(); - double targetProbability = random.NextDouble(); - double targetReliability = random.NextDouble(); - double calculatedProbability = random.NextDouble(); - double calculatedReliability = random.NextDouble(); - var convergence = random.NextEnumValue(); + var output = new TestHydraulicBoundaryLocationOutput(result); + var generalResult = new TestGeneralResult(); + // Call - var output = new HydraulicBoundaryLocationOutput(result, targetProbability, - targetReliability, - calculatedProbability, - calculatedReliability, - convergence, - null); + output.SetIllustrationPoints(generalResult); // Assert - Assert.AreEqual(result, output.Result, output.Result.GetAccuracy()); - Assert.AreEqual(targetProbability, output.TargetProbability); - Assert.AreEqual(targetReliability, output.TargetReliability, output.TargetReliability.GetAccuracy()); - Assert.AreEqual(calculatedProbability, output.CalculatedProbability); - Assert.AreEqual(calculatedReliability, output.CalculatedReliability, output.CalculatedReliability.GetAccuracy()); - Assert.AreEqual(convergence, output.CalculationConvergence); - Assert.IsNull(output.GeneralResult); - Assert.IsFalse(output.HasIllustrationPoints); + Assert.AreSame(generalResult, output.GeneralResult); + Assert.IsTrue(output.HasIllustrationPoints); } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs (revision 7b361b577c778a137cbdb78603822412e189b93e) @@ -0,0 +1,57 @@ +// Copyright (C) Stichting Deltares 2017. 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 NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; + +namespace Ringtoets.Common.Data.TestUtil.Test.IllustrationPoints +{ + [TestFixture] + public class TestGeneralResultTest + { + [Test] + public void Constructor_ExpectedProperties() + { + // Call + var generalResult = new TestGeneralResult(); + + // Assert + Assert.IsInstanceOf(generalResult); + Assert.AreEqual(0, generalResult.Beta); + AssertWindDirection(new TestWindDirection(), generalResult.GoverningWindirection); + Assert.IsEmpty(generalResult.Stochasts); + Assert.IsEmpty(generalResult.WindDirectionClosingIllustrationPoints); + } + + private static void AssertWindDirection(WindDirection expected, WindDirection actual) + { + if (expected == null) + { + Assert.IsNull(actual); + return; + } + Assert.AreEqual(expected.Name, actual.Name); + Assert.AreEqual(expected.Angle, actual.Angle); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj =================================================================== diff -u -rf1e6b4ad5dddc6e771288f17a0b619d6dd23ec07 -r7b361b577c778a137cbdb78603822412e189b93e --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision f1e6b4ad5dddc6e771288f17a0b619d6dd23ec07) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision 7b361b577c778a137cbdb78603822412e189b93e) @@ -55,6 +55,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestGeneralResult.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestGeneralResult.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestGeneralResult.cs (revision 7b361b577c778a137cbdb78603822412e189b93e) @@ -0,0 +1,41 @@ +// Copyright (C) Stichting Deltares 2017. 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.Linq; +using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; + +namespace Ringtoets.Common.Data.TestUtil.IllustrationPoints +{ + /// + /// A simple general result which can be used for testing. + /// + public class TestGeneralResult : GeneralResult + { + /// + /// Creates a . + /// + public TestGeneralResult() + : base(0, + new TestWindDirection(), + Enumerable.Empty(), + Enumerable.Empty()) {} + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj =================================================================== diff -u -rf1e6b4ad5dddc6e771288f17a0b619d6dd23ec07 -r7b361b577c778a137cbdb78603822412e189b93e --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision f1e6b4ad5dddc6e771288f17a0b619d6dd23ec07) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision 7b361b577c778a137cbdb78603822412e189b93e) @@ -59,6 +59,7 @@ +