Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismExtensions.cs
===================================================================
diff -u -r9bb285c6eb5b2ed43bf4293caa51baa5175b7080 -r8a3d8f25e6cea125fda6783db41e88aca1864ba7
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismExtensions.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensions.cs) (revision 9bb285c6eb5b2ed43bf4293caa51baa5175b7080)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismExtensions.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensions.cs) (revision 8a3d8f25e6cea125fda6783db41e88aca1864ba7)
@@ -25,7 +25,6 @@
using System.Linq;
using Core.Common.Base.Data;
using Ringtoets.Common.Data.AssessmentSection;
-using Ringtoets.Common.Data.Contribution;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
@@ -37,66 +36,6 @@
public static class GrassCoverErosionOutwardsFailureMechanismExtensions
{
///
- /// Gets the normative assessment level for a .
- ///
- /// The assessment section to get the normative assessment level from.
- /// The failure mechanism to get the normative assessment level from.
- /// The hydraulic boundary location to get the normative assessment level for.
- /// The normative assessment level or when:
- ///
- /// - is null;
- /// - is not part of ;
- /// - is not part of ;
- /// - contains no corresponding calculation output.
- ///
- ///
- /// Thrown when
- /// or is null.
- /// Thrown when
- /// contains an invalid value of .
- /// Thrown when
- /// contains a valid value of , but unsupported.
- public static RoundedDouble GetNormativeAssessmentLevel(this GrassCoverErosionOutwardsFailureMechanism failureMechanism,
- IAssessmentSection assessmentSection,
- HydraulicBoundaryLocation hydraulicBoundaryLocation)
- {
- if (failureMechanism == null)
- {
- throw new ArgumentNullException(nameof(failureMechanism));
- }
-
- if (assessmentSection == null)
- {
- throw new ArgumentNullException(nameof(assessmentSection));
- }
-
- NormType normType = assessmentSection.FailureMechanismContribution.NormativeNorm;
-
- if (!Enum.IsDefined(typeof(NormType), normType))
- {
- throw new InvalidEnumArgumentException(nameof(normType),
- (int) normType,
- typeof(NormType));
- }
-
- IEnumerable calculations;
-
- switch (normType)
- {
- case NormType.Signaling:
- calculations = failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm;
- break;
- case NormType.LowerLimit:
- calculations = failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm;
- break;
- default:
- throw new NotSupportedException();
- }
-
- return GetAssessmentLevelFromCalculations(hydraulicBoundaryLocation, calculations);
- }
-
- ///
/// Gets the assessment level for a based on .
///
/// The assessment section to get the assessment level from.
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs
===================================================================
diff -u -re3b58f9f74ce55c3334ca41ba325a7e5ff94052a -r8a3d8f25e6cea125fda6783db41e88aca1864ba7
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs) (revision e3b58f9f74ce55c3334ca41ba325a7e5ff94052a)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs) (revision 8a3d8f25e6cea125fda6783db41e88aca1864ba7)
@@ -20,14 +20,11 @@
// All rights reserved.
using System;
-using System.Collections;
using System.ComponentModel;
-using System.Linq;
using Core.Common.Base.Data;
using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Common.Data.AssessmentSection;
-using Ringtoets.Common.Data.Contribution;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Data.TestUtil;
@@ -39,130 +36,6 @@
public class GrassCoverErosionOutwardsFailureMechanismExtensionsTest
{
[Test]
- public void GetNormativeAssessmentLevel_FailureMechanismNull_ThrowsArgumentNullException()
- {
- // Call
- TestDelegate test = () => GrassCoverErosionOutwardsFailureMechanismExtensions.GetNormativeAssessmentLevel(null,
- new AssessmentSectionStub(),
- new TestHydraulicBoundaryLocation());
-
- // Assert
- string paramName = Assert.Throws(test).ParamName;
- Assert.AreEqual("failureMechanism", paramName);
- }
-
- [Test]
- public void GetNormativeAssessmentLevel_AssessmentSectionNull_ThrowsArgumentNullException()
- {
- // Setup
- var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
-
- // Call
- TestDelegate test = () => failureMechanism.GetNormativeAssessmentLevel(null,
- new TestHydraulicBoundaryLocation());
-
- // Assert
- string paramName = Assert.Throws(test).ParamName;
- Assert.AreEqual("assessmentSection", paramName);
- }
-
- [Test]
- public void GetNormativeAssessmentLevel_AssessmentSectionWithInvalidNormType_ThrowsInvalidEnumArgumentException()
- {
- // Setup
- const int invalidValue = 9999;
-
- var assessmentSection = new AssessmentSectionStub();
- assessmentSection.FailureMechanismContribution.NormativeNorm = (NormType) invalidValue;
-
- var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
-
- // Call
- TestDelegate test = () => failureMechanism.GetNormativeAssessmentLevel(assessmentSection,
- new TestHydraulicBoundaryLocation());
-
- // Assert
- string expectedMessage = $"The value of argument 'normType' ({invalidValue}) is invalid for Enum type '{nameof(NormType)}'.";
- string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage).ParamName;
- Assert.AreEqual("normType", parameterName);
- }
-
- [Test]
- public void GetNormativeAssessmentLevel_HydraulicBoundaryLocationNull_ReturnsNaN()
- {
- // Setup
- var assessmentSection = new AssessmentSectionStub();
- var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
-
- assessmentSection.FailureMechanismContribution.NormativeNorm = new Random(32).NextEnumValue();
-
- // Call
- RoundedDouble normativeAssessmentLevel = failureMechanism.GetNormativeAssessmentLevel(assessmentSection,
- null);
-
- // Assert
- Assert.IsNaN(normativeAssessmentLevel);
- }
-
- [Test]
- public void GetNormativeAssessmentLevel_NoCorrespondingCalculation_ReturnsNaN()
- {
- var assessmentSection = new AssessmentSectionStub();
- var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
-
- assessmentSection.FailureMechanismContribution.NormativeNorm = new Random(32).NextEnumValue();
-
- // Call
- RoundedDouble normativeAssessmentLevel = failureMechanism.GetNormativeAssessmentLevel(assessmentSection,
- new TestHydraulicBoundaryLocation());
-
- // Assert
- Assert.IsNaN(normativeAssessmentLevel);
- }
-
- [Test]
- public void GetNormativeAssessmentLevel_NoCorrespondingAssessmentLevelOutput_ReturnsNaN()
- {
- var assessmentSection = new AssessmentSectionStub();
- var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
-
- assessmentSection.FailureMechanismContribution.NormativeNorm = new Random(32).NextEnumValue();
- assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
- {
- hydraulicBoundaryLocation
- });
-
- var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
-
- // Call
- RoundedDouble normativeAssessmentLevel = failureMechanism.GetNormativeAssessmentLevel(assessmentSection,
- hydraulicBoundaryLocation);
-
- // Assert
- Assert.IsNaN(normativeAssessmentLevel);
- }
-
- [Test]
- [TestCaseSource(nameof(DifferentNormTypes))]
- public void GetNormativeAssessmentLevel_HydraulicBoundaryLocationWithOutput_ReturnsCorrespondingAssessmentLevel(
- IAssessmentSection assessmentSection,
- GrassCoverErosionOutwardsFailureMechanism failureMechanism,
- HydraulicBoundaryLocation hydraulicBoundaryLocation,
- NormType normType,
- RoundedDouble expectedNormativeAssessmentLevel)
- {
- // Setup
- assessmentSection.FailureMechanismContribution.NormativeNorm = normType;
-
- // Call
- RoundedDouble normativeAssessmentLevel = failureMechanism.GetNormativeAssessmentLevel(assessmentSection,
- hydraulicBoundaryLocation);
-
- // Assert
- Assert.AreEqual(expectedNormativeAssessmentLevel, normativeAssessmentLevel);
- }
-
- [Test]
public void GetAssessmentLevel_FailureMechanismNull_ThrowsArgumentNullException()
{
// Call
@@ -284,35 +157,5 @@
// Assert
Assert.AreEqual(expectedAssessmentLevel, assessmentLevel);
}
-
- private static IEnumerable DifferentNormTypes()
- {
- var assessmentSection = new AssessmentSectionStub();
- var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
- var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
-
- GrassCoverErosionOutwardsHydraulicBoundaryLocationsTestHelper.SetHydraulicBoundaryLocations(
- failureMechanism, assessmentSection,
- new[]
- {
- hydraulicBoundaryLocation
- }, true);
-
- yield return new TestCaseData(
- assessmentSection,
- failureMechanism,
- hydraulicBoundaryLocation,
- NormType.Signaling,
- failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm.ElementAt(0).Output.Result
- ).SetName("SignalingNorm");
-
- yield return new TestCaseData(
- assessmentSection,
- failureMechanism,
- hydraulicBoundaryLocation,
- NormType.LowerLimit,
- failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm.ElementAt(0).Output.Result
- ).SetName("LowerLimitNorm");
- }
}
}
\ No newline at end of file