Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresCalculationTest.cs =================================================================== diff -u -rfdbe190cbae73817b0137f3c1433882bde956948 -ra1660e4c72d2ba7a6c97dff29ca732ee292af5f4 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresCalculationTest.cs (.../StructuresCalculationTest.cs) (revision fdbe190cbae73817b0137f3c1433882bde956948) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresCalculationTest.cs (.../StructuresCalculationTest.cs) (revision a1660e4c72d2ba7a6c97dff29ca732ee292af5f4) @@ -46,7 +46,6 @@ Assert.AreEqual("Nieuwe berekening", calculation.Name); Assert.IsNotNull(calculation.InputParameters); Assert.IsNull(calculation.Comments.Body); - Assert.IsFalse(calculation.HasOutput); Assert.IsNull(calculation.Output); } @@ -99,7 +98,7 @@ } [Test] - [TestCaseSource(nameof(GetStructuresCalculations))] + [TestCaseSource(nameof(GetCalculations))] public void ShouldCalculate_Always_ReturnsExpectedValue(TestStructuresCalculation calculation, bool expectedShouldCalculate) { @@ -202,7 +201,7 @@ public override void SynchronizeStructureInput() {} } - private static IEnumerable GetStructuresCalculations() + private static IEnumerable GetCalculations() { yield return new TestCaseData(new TestStructuresCalculation { Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs =================================================================== diff -u -r65813dfccc471aa70736029d498d71ac0403c02d -ra1660e4c72d2ba7a6c97dff29ca732ee292af5f4 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs (.../GrassCoverErosionInwardsCalculation.cs) (revision 65813dfccc471aa70736029d498d71ac0403c02d) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs (.../GrassCoverErosionInwardsCalculation.cs) (revision a1660e4c72d2ba7a6c97dff29ca732ee292af5f4) @@ -57,7 +57,10 @@ { get { - return !HasOutput; + return !HasOutput + || Output.OvertoppingOutput.HasGeneralResult != InputParameters.ShouldOvertoppingOutputIllustrationPointsBeCalculated + || Output.DikeHeightOutput.HasGeneralResult != InputParameters.ShouldDikeHeightIllustrationPointsBeCalculated + || Output.OvertoppingRateOutput.HasGeneralResult != InputParameters.ShouldOvertoppingRateIllustrationPointsBeCalculated; } } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs =================================================================== diff -u -r6df492af2166d167f1a154b7997c85a4118b1759 -ra1660e4c72d2ba7a6c97dff29ca732ee292af5f4 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs (.../GrassCoverErosionInwardsCalculationTest.cs) (revision 6df492af2166d167f1a154b7997c85a4118b1759) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs (.../GrassCoverErosionInwardsCalculationTest.cs) (revision a1660e4c72d2ba7a6c97dff29ca732ee292af5f4) @@ -19,10 +19,12 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using Core.Common.Base; using Core.Common.Data.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; using Ringtoets.GrassCoverErosionInwards.Data.TestUtil; namespace Ringtoets.GrassCoverErosionInwards.Data.Test @@ -42,7 +44,6 @@ Assert.AreEqual("Nieuwe berekening", calculation.Name); Assert.IsNotNull(calculation.InputParameters); - Assert.IsFalse(calculation.HasOutput); Assert.IsNull(calculation.Comments.Body); Assert.IsNull(calculation.Output); Assert.IsNull(calculation.InputParameters.DikeProfile); @@ -129,6 +130,18 @@ } [Test] + [TestCaseSource(nameof(GetCalculations))] + public void ShouldCalculate_Always_ReturnsExpectedValue(GrassCoverErosionInwardsCalculation calculation, + bool expectedShouldCalculate) + { + // Call + bool shouldCalculate = calculation.ShouldCalculate; + + // Assert + Assert.AreEqual(expectedShouldCalculate, shouldCalculate); + } + + [Test] public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues() { // Setup @@ -171,5 +184,116 @@ return calculation; } + + private static IEnumerable GetCalculations() + { + var overtoppingOutputWithoutGeneralResult = new TestOvertoppingOutput(1.0); + var overtoppingOutputWithGeneralResult = new OvertoppingOutput(1.0, + true, + 1.0, + new TestGeneralResultFaultTreeIllustrationPoint()); + + var dikeHeightOutputWithoutGeneralResult = new TestDikeHeightOutput(1.0); + var dikeHeightOutputWithGeneralResult = new TestDikeHeightOutput(new TestGeneralResultFaultTreeIllustrationPoint()); + + var overtoppingRateOutputWithoutGeneralResult = new TestOvertoppingRateOutput(1.0); + var overtoppingRateOutputWithGeneralResult = new TestOvertoppingRateOutput(new TestGeneralResultFaultTreeIllustrationPoint()); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + ShouldOvertoppingOutputIllustrationPointsBeCalculated = true, + ShouldOvertoppingRateIllustrationPointsBeCalculated = true, + ShouldDikeHeightIllustrationPointsBeCalculated = true + }, + Output = new GrassCoverErosionInwardsOutput(overtoppingOutputWithGeneralResult, + dikeHeightOutputWithGeneralResult, + overtoppingRateOutputWithGeneralResult) + }, false) + .SetName("OutputSufficientScenario1"); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(overtoppingOutputWithoutGeneralResult, + dikeHeightOutputWithoutGeneralResult, + overtoppingRateOutputWithoutGeneralResult) + }, false) + .SetName("OutputSufficientScenario2"); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation(), true) + .SetName("NoOutputScenario1"); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + ShouldOvertoppingOutputIllustrationPointsBeCalculated = true, + ShouldOvertoppingRateIllustrationPointsBeCalculated = true, + ShouldDikeHeightIllustrationPointsBeCalculated = true + } + }, true) + .SetName("NoOutputScenario2"); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(overtoppingOutputWithGeneralResult, + dikeHeightOutputWithoutGeneralResult, + overtoppingRateOutputWithoutGeneralResult) + }, true) + .SetName("OvertoppingOutputWithRedundantGeneralResult"); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + ShouldOvertoppingOutputIllustrationPointsBeCalculated = true + }, + Output = new GrassCoverErosionInwardsOutput(overtoppingOutputWithoutGeneralResult, + dikeHeightOutputWithoutGeneralResult, + overtoppingRateOutputWithoutGeneralResult) + }, true) + .SetName("OvertoppingOutputWithMissingGeneralResult"); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(overtoppingOutputWithoutGeneralResult, + dikeHeightOutputWithGeneralResult, + overtoppingRateOutputWithoutGeneralResult) + }, true) + .SetName("DikeHeightOutputWithRedundantGeneralResult"); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + ShouldDikeHeightIllustrationPointsBeCalculated = true + }, + Output = new GrassCoverErosionInwardsOutput(overtoppingOutputWithoutGeneralResult, + dikeHeightOutputWithoutGeneralResult, + overtoppingRateOutputWithoutGeneralResult) + }, true) + .SetName("DikeHeightOutputWithMissingGeneralResult"); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(overtoppingOutputWithoutGeneralResult, + dikeHeightOutputWithoutGeneralResult, + overtoppingRateOutputWithGeneralResult) + }, true) + .SetName("OvertoppingRateOutputWithRedundantGeneralResult"); + + yield return new TestCaseData(new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + ShouldOvertoppingRateIllustrationPointsBeCalculated = true + }, + Output = new GrassCoverErosionInwardsOutput(overtoppingOutputWithoutGeneralResult, + dikeHeightOutputWithoutGeneralResult, + overtoppingRateOutputWithoutGeneralResult) + }, true) + .SetName("OvertoppingRateOutputWithMissingGeneralResult"); + } } } \ No newline at end of file