Index: Ringtoets/Common/src/Ringtoets.Common.Data/Hydraulics/HydraulicBoundaryLocationCalculation.cs =================================================================== diff -u -rda7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7 -r0e2d1a46c627af6d19cdf21dff840716bac84045 --- Ringtoets/Common/src/Ringtoets.Common.Data/Hydraulics/HydraulicBoundaryLocationCalculation.cs (.../HydraulicBoundaryLocationCalculation.cs) (revision da7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Hydraulics/HydraulicBoundaryLocationCalculation.cs (.../HydraulicBoundaryLocationCalculation.cs) (revision 0e2d1a46c627af6d19cdf21dff840716bac84045) @@ -21,13 +21,14 @@ using System; using Core.Common.Base; +using Ringtoets.Common.Data.Calculation; namespace Ringtoets.Common.Data.Hydraulics { /// /// This class holds information about a calculation for a hydraulic boundary location. /// - public class HydraulicBoundaryLocationCalculation : Observable + public class HydraulicBoundaryLocationCalculation : Observable, ICalculatable { /// /// Creates a new instance of . @@ -71,17 +72,11 @@ } } - /// - /// Gets a value indicating whether the calculation has already been calculated. - /// - /// true if the calculation is fully calculated, false otherwise. - /// A calculation is fully calculated, depending on whether the illustration points - /// are set to be calculated. - public bool IsCalculated + public bool ShouldCalculate { get { - return HasOutput && InputParameters.ShouldIllustrationPointsBeCalculated == Output.HasGeneralResult; + return !HasOutput || InputParameters.ShouldIllustrationPointsBeCalculated != Output.HasGeneralResult; } } } Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Hydraulics/HydraulicBoundaryLocationCalculationTest.cs =================================================================== diff -u -rda7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7 -r0e2d1a46c627af6d19cdf21dff840716bac84045 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Hydraulics/HydraulicBoundaryLocationCalculationTest.cs (.../HydraulicBoundaryLocationCalculationTest.cs) (revision da7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Hydraulics/HydraulicBoundaryLocationCalculationTest.cs (.../HydraulicBoundaryLocationCalculationTest.cs) (revision 0e2d1a46c627af6d19cdf21dff840716bac84045) @@ -23,6 +23,7 @@ using System.Collections.Generic; using Core.Common.Base; using NUnit.Framework; +using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; @@ -53,6 +54,7 @@ var calculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation); // Assert + Assert.IsInstanceOf(calculation); Assert.IsInstanceOf(calculation); Assert.AreSame(hydraulicBoundaryLocation, calculation.HydraulicBoundaryLocation); Assert.IsNotNull(calculation.InputParameters); @@ -78,48 +80,65 @@ } [Test] - [TestCaseSource(nameof(GetHydraulicBoundaryLocationCalculations))] - public void IsCalculated_Always_ReturnIsCalculated(HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation, - bool expectedIsCalculated) + [TestCaseSource(nameof(GetCalculations))] + public void ShouldCalculate_Always_ReturnsExpectedValue(HydraulicBoundaryLocationCalculation calculation, + bool expectedShouldCalculate) { // Call - bool isCalculated = hydraulicBoundaryLocationCalculation.IsCalculated; + bool shouldCalculate = calculation.ShouldCalculate; // Assert - Assert.AreEqual(expectedIsCalculated, isCalculated); + Assert.AreEqual(expectedShouldCalculate, shouldCalculate); } - private static IEnumerable GetHydraulicBoundaryLocationCalculations() + private static IEnumerable GetCalculations() { + var outputWithoutGeneralResult = new TestHydraulicBoundaryLocationCalculationOutput(1.0, CalculationConvergence.CalculatedConverged); + var outputWithGeneralResult = new TestHydraulicBoundaryLocationCalculationOutput(1.0, new TestGeneralResultSubMechanismIllustrationPoint()); + yield return new TestCaseData(new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()) - { - InputParameters = { - ShouldIllustrationPointsBeCalculated = true - }, - Output = new TestHydraulicBoundaryLocationCalculationOutput(1.0, CalculationConvergence.CalculatedConverged) - }, false); + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + }, + Output = outputWithGeneralResult + }, false) + .SetName("OutputSufficientScenario1"); - yield return new TestCaseData(new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()), false); + yield return new TestCaseData(new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()) + { + Output = outputWithoutGeneralResult + }, false) + .SetName("OutputSufficientScenario2"); + yield return new TestCaseData(new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()), true) + .SetName("NoOutputScenario1"); + yield return new TestCaseData(new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()) - { - Output = new TestHydraulicBoundaryLocationCalculationOutput(1.0, CalculationConvergence.CalculatedConverged) - }, true); + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + } + }, true) + .SetName("NoOutputScenario2"); yield return new TestCaseData(new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()) - { - InputParameters = { - ShouldIllustrationPointsBeCalculated = true - }, - Output = new TestHydraulicBoundaryLocationCalculationOutput(1.0, new TestGeneralResultSubMechanismIllustrationPoint()) - }, true); + Output = outputWithGeneralResult + }, true) + .SetName("OutputWithRedundantGeneralResult"); yield return new TestCaseData(new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()) - { - Output = new TestHydraulicBoundaryLocationCalculationOutput(1.0, new TestGeneralResultSubMechanismIllustrationPoint()) - }, false); + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = true + }, + Output = outputWithoutGeneralResult + }, true) + .SetName("OutputWithMissingGeneralResult"); } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresCalculationTest.cs =================================================================== diff -u -ra1660e4c72d2ba7a6c97dff29ca732ee292af5f4 -r0e2d1a46c627af6d19cdf21dff840716bac84045 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresCalculationTest.cs (.../StructuresCalculationTest.cs) (revision a1660e4c72d2ba7a6c97dff29ca732ee292af5f4) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresCalculationTest.cs (.../StructuresCalculationTest.cs) (revision 0e2d1a46c627af6d19cdf21dff840716bac84045) @@ -203,19 +203,22 @@ private static IEnumerable GetCalculations() { + var outputWithoutGeneralResult = new TestStructuresOutput(); + var outputWithGeneralResult = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()); + yield return new TestCaseData(new TestStructuresCalculation { InputParameters = { ShouldIllustrationPointsBeCalculated = true }, - Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()) + Output = outputWithGeneralResult }, false) .SetName("OutputSufficientScenario1"); yield return new TestCaseData(new TestStructuresCalculation { - Output = new TestStructuresOutput() + Output = outputWithoutGeneralResult }, false) .SetName("OutputSufficientScenario2"); @@ -233,7 +236,7 @@ yield return new TestCaseData(new TestStructuresCalculation { - Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()) + Output = outputWithGeneralResult }, true) .SetName("OutputWithRedundantGeneralResult"); @@ -243,7 +246,7 @@ { ShouldIllustrationPointsBeCalculated = true }, - Output = new TestStructuresOutput() + Output = outputWithoutGeneralResult }, true) .SetName("OutputWithMissingGeneralResult"); }