Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs =================================================================== diff -u -ra6d909b9368f5596488c9852e16a9779e01dc0a7 -r5a167077bb2843403a6ec96f038f9eec119174dd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs (.../GrassCoverErosionInwardsOutputProperties.cs) (revision a6d909b9368f5596488c9852e16a9779e01dc0a7) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs (.../GrassCoverErosionInwardsOutputProperties.cs) (revision 5a167077bb2843403a6ec96f038f9eec119174dd) @@ -31,7 +31,6 @@ using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.TypeConverters; -using Ringtoets.Common.Service; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Forms.Properties; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -73,10 +72,8 @@ Data = grassCoverErosionInwardsOutput; - derivedOvertoppingOutput = ProbabilityAssessmentService.Calculate(assessmentSection.FailureMechanismContribution.Norm, - failureMechanism.Contribution, - failureMechanism.GeneralInput.N, - grassCoverErosionInwardsOutput.OvertoppingOutput.Reliability); + derivedOvertoppingOutput = GrassCoverErosionInwardsProbabilityAssessmentOutputFactory.Create(grassCoverErosionInwardsOutput.OvertoppingOutput, + failureMechanism, assessmentSection); } [DynamicVisibleValidationMethod] Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/OvertoppingOutputProperties.cs =================================================================== diff -u -rac96d7c315129af851634ed5a4a6800b59ede718 -r5a167077bb2843403a6ec96f038f9eec119174dd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/OvertoppingOutputProperties.cs (.../OvertoppingOutputProperties.cs) (revision ac96d7c315129af851634ed5a4a6800b59ede718) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/OvertoppingOutputProperties.cs (.../OvertoppingOutputProperties.cs) (revision 5a167077bb2843403a6ec96f038f9eec119174dd) @@ -28,7 +28,9 @@ using Core.Common.Gui.PropertyBag; using Core.Common.Util.Attributes; using Core.Common.Util.Extensions; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.GrassCoverErosionInwards.Data; @@ -42,19 +44,39 @@ /// public class OvertoppingOutputProperties : ObjectProperties { + private readonly ProbabilityAssessmentOutput derivedOutput; + /// /// Creates a new instance of . /// /// The overtopping output to create the object properties for. - /// Thrown when is null. - public OvertoppingOutputProperties(OvertoppingOutput overtoppingOutput) + /// The failure mechanism the output belongs to. + /// The assessment section the output belongs to. + /// Thrown when any parameter is null. + public OvertoppingOutputProperties(OvertoppingOutput overtoppingOutput, + GrassCoverErosionInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) { if (overtoppingOutput == null) { throw new ArgumentNullException(nameof(overtoppingOutput)); } + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + Data = overtoppingOutput; + + derivedOutput = GrassCoverErosionInwardsProbabilityAssessmentOutputFactory.Create(overtoppingOutput, + failureMechanism, + assessmentSection); } [PropertyOrder(1)] @@ -65,7 +87,7 @@ { get { - return ProbabilityFormattingHelper.Format(data.ProbabilityAssessmentOutput.RequiredProbability); + return ProbabilityFormattingHelper.Format(derivedOutput.RequiredProbability); } } @@ -77,7 +99,7 @@ { get { - return data.ProbabilityAssessmentOutput.RequiredReliability; + return derivedOutput.RequiredReliability; } } @@ -89,7 +111,7 @@ { get { - return ProbabilityFormattingHelper.Format(data.ProbabilityAssessmentOutput.Probability); + return ProbabilityFormattingHelper.Format(derivedOutput.Probability); } } @@ -101,7 +123,7 @@ { get { - return data.ProbabilityAssessmentOutput.Reliability; + return derivedOutput.Reliability; } } @@ -113,7 +135,7 @@ { get { - return data.ProbabilityAssessmentOutput.FactorOfSafety; + return derivedOutput.FactorOfSafety; } } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj =================================================================== diff -u -r6ac1d016e76120e778964de3ad7e2c0d6c837669 -r5a167077bb2843403a6ec96f038f9eec119174dd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 6ac1d016e76120e778964de3ad7e2c0d6c837669) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 5a167077bb2843403a6ec96f038f9eec119174dd) @@ -142,11 +142,6 @@ Ringtoets.Common.Forms False - - {D951D6DA-FE83-4920-9FDB-63BF96480B54} - Ringtoets.Common.Service - False - {90DE728E-48EF-4665-AB38-3D88E41D9F4D} Ringtoets.GrassCoverErosionInwards.Data Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -r6ac1d016e76120e778964de3ad7e2c0d6c837669 -r5a167077bb2843403a6ec96f038f9eec119174dd --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 6ac1d016e76120e778964de3ad7e2c0d6c837669) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 5a167077bb2843403a6ec96f038f9eec119174dd) @@ -93,7 +93,9 @@ }; yield return new PropertyInfo { - CreateInstance = context => new OvertoppingOutputProperties(context.WrappedData.Output.OvertoppingOutput) + CreateInstance = context => new OvertoppingOutputProperties(context.WrappedData.Output.OvertoppingOutput, + context.FailureMechanism, + context.AssessmentSection) }; yield return new PropertyInfo { Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/OvertoppingOutputPropertiesTest.cs =================================================================== diff -u -r6306f61e82936c6bb6db70c4a185243cb07f00af -r5a167077bb2843403a6ec96f038f9eec119174dd --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/OvertoppingOutputPropertiesTest.cs (.../OvertoppingOutputPropertiesTest.cs) (revision 6306f61e82936c6bb6db70c4a185243cb07f00af) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/OvertoppingOutputPropertiesTest.cs (.../OvertoppingOutputPropertiesTest.cs) (revision 5a167077bb2843403a6ec96f038f9eec119174dd) @@ -26,6 +26,8 @@ using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Data.TestUtil; @@ -57,35 +59,86 @@ private const string illustrationPointsCategoryName = "Illustratiepunten"; [Test] - public void Constructor_OvertoppingOutput_ExpectedValues() + public void Constructor_ExpectedValues() { // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + var overtoppingOutput = new TestOvertoppingOutput(0.5); // Call - var properties = new OvertoppingOutputProperties(overtoppingOutput); + var properties = new OvertoppingOutputProperties(overtoppingOutput, + failureMechanism, + assessmentSection); // Assert Assert.IsInstanceOf>(properties); Assert.AreSame(overtoppingOutput, properties.Data); + mocks.VerifyAll(); } [Test] public void Constructor_OvertoppingOutputNull_ThrowsArgumentNullException() { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + // Call - TestDelegate test = () => new OvertoppingOutputProperties(null); + TestDelegate test = () => new OvertoppingOutputProperties(null, failureMechanism, assessmentSection); // Assert var exception = Assert.Throws(test); Assert.AreEqual("overtoppingOutput", exception.ParamName); + mocks.VerifyAll(); } [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => new OvertoppingOutputProperties(new TestOvertoppingOutput(0), null, assessmentSection); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new OvertoppingOutputProperties(new TestOvertoppingOutput(0), + new GrassCoverErosionInwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] public void GetProperties_WithData_ReturnExpectedValues() { // Setup - var random = new Random(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + + var random = new Random(39); double waveHeight = random.NextDouble(); bool isOvertoppingDominant = random.NextBoolean(); double requiredProbability = random.NextDouble(); @@ -108,18 +161,20 @@ generalResult); // Call - var properties = new OvertoppingOutputProperties(overtoppingOutput); + var properties = new OvertoppingOutputProperties(overtoppingOutput, + failureMechanism, + assessmentSection); // Assert Assert.AreEqual(2, properties.WaveHeight.NumberOfDecimalPlaces); Assert.AreEqual(waveHeight, properties.WaveHeight, properties.WaveHeight.GetAccuracy()); Assert.AreEqual(reliability, properties.Reliability, properties.Reliability.GetAccuracy()); - Assert.AreEqual(requiredReliability, properties.RequiredReliability, properties.RequiredReliability.GetAccuracy()); + Assert.AreEqual(double.PositiveInfinity, properties.RequiredReliability, properties.RequiredReliability.GetAccuracy()); Assert.AreEqual(3, properties.FactorOfSafety.NumberOfDecimalPlaces); - Assert.AreEqual(factorOfSafety, properties.FactorOfSafety, properties.FactorOfSafety.GetAccuracy()); + Assert.AreEqual(0, properties.FactorOfSafety, properties.FactorOfSafety.GetAccuracy()); - Assert.AreEqual(ProbabilityFormattingHelper.Format(requiredProbability), properties.RequiredProbability); - Assert.AreEqual(ProbabilityFormattingHelper.Format(probability), properties.Probability); + Assert.AreEqual(ProbabilityFormattingHelper.Format(0), properties.RequiredProbability); + Assert.AreEqual(ProbabilityFormattingHelper.Format(0.25), properties.Probability); Assert.AreEqual(isOvertoppingDominant, properties.IsOvertoppingDominant); @@ -144,20 +199,27 @@ Assert.AreEqual(nrOfExpectedTopLevelIllustrationPoints, properties.IllustrationPoints.Length); CollectionAssert.AreEqual(generalResult.TopLevelIllustrationPoints, properties.IllustrationPoints.Select(i => i.Data)); + mocks.VerifyAll(); } [Test] public void IllustrationPoints_WithoutGeneralResult_ReturnsEmptyTopLevelFaultTreeIllustrationPointPropertiesArray() { // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + var overtoppingOutput = new TestOvertoppingOutput(0.5); - var properties = new OvertoppingOutputProperties(overtoppingOutput); + var properties = new OvertoppingOutputProperties(overtoppingOutput, failureMechanism, assessmentSection); // Call TopLevelFaultTreeIllustrationPointProperties[] illustrationPoints = properties.IllustrationPoints; // Assert Assert.IsEmpty(illustrationPoints); + mocks.VerifyAll(); } [Test] @@ -166,6 +228,11 @@ public void PropertyAttributes_NoGeneralResult_ReturnExpectedValues(double waveHeight) { // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + var probabilityAssessmentOutput = new TestProbabilityAssessmentOutput(); var overtoppingOutput = new OvertoppingOutput(waveHeight, true, @@ -174,7 +241,7 @@ null); // Call - var properties = new OvertoppingOutputProperties(overtoppingOutput); + var properties = new OvertoppingOutputProperties(overtoppingOutput, failureMechanism, assessmentSection); // Assert int propertiesCount = overtoppingOutput.HasWaveHeight ? 7 : 6; @@ -237,6 +304,7 @@ "Overslag dominant [-]", "Is het resultaat van de overslag deelberekening dominant over de overloop deelberekening.", true); + mocks.VerifyAll(); } [Test] @@ -245,6 +313,11 @@ public void PropertyAttributes_HasGeneralResult_ReturnExpectedValues(double waveHeight) { // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + var probabilityAssessmentOutput = new TestProbabilityAssessmentOutput(); var overtoppingOutput = new OvertoppingOutput(waveHeight, true, @@ -253,7 +326,7 @@ new TestGeneralResultFaultTreeIllustrationPoint()); // Call - var properties = new OvertoppingOutputProperties(overtoppingOutput); + var properties = new OvertoppingOutputProperties(overtoppingOutput, failureMechanism, assessmentSection); // Assert int propertiesCount = overtoppingOutput.HasWaveHeight ? 11 : 10; @@ -344,6 +417,7 @@ "Illustratiepunten", "De lijst van illustratiepunten voor de berekening.", true); + mocks.VerifyAll(); } } } \ No newline at end of file