Index: Riskeer/Common/src/Riskeer.Common.Data/AssessmentSection/AssessmentSectionExtensions.cs
===================================================================
diff -u -r4b889a77a0b2a44d9eadc54540334140415177c8 -rdc66d2df32013dc5dac0f0bfd07d6b474ec4a9d8
--- Riskeer/Common/src/Riskeer.Common.Data/AssessmentSection/AssessmentSectionExtensions.cs (.../AssessmentSectionExtensions.cs) (revision 4b889a77a0b2a44d9eadc54540334140415177c8)
+++ Riskeer/Common/src/Riskeer.Common.Data/AssessmentSection/AssessmentSectionExtensions.cs (.../AssessmentSectionExtensions.cs) (revision dc66d2df32013dc5dac0f0bfd07d6b474ec4a9d8)
@@ -24,8 +24,6 @@
using System.ComponentModel;
using System.Linq;
using Core.Common.Base.Data;
-using Riskeer.AssemblyTool.Data;
-using Riskeer.Common.Data.AssemblyTool;
using Riskeer.Common.Data.Contribution;
using Riskeer.Common.Data.Hydraulics;
@@ -165,56 +163,6 @@
}
///
- /// Gets the norm based on .
- ///
- /// The assessment section to get the norm from.
- /// The category type to use while obtaining the norm.
- /// The norm corresponding to the provided category type.
- /// Thrown when
- /// is null.
- /// Thrown when
- /// is an invalid .
- /// Thrown when
- /// is a valid but unsupported .
- public static double GetNorm(this IAssessmentSection assessmentSection,
- AssessmentSectionCategoryType categoryType)
- {
- if (assessmentSection == null)
- {
- throw new ArgumentNullException(nameof(assessmentSection));
- }
-
- if (!Enum.IsDefined(typeof(AssessmentSectionCategoryType), categoryType))
- {
- throw new InvalidEnumArgumentException(nameof(categoryType),
- (int) categoryType,
- typeof(AssessmentSectionCategoryType));
- }
-
- IEnumerable categories = AssemblyToolCategoriesFactory.CreateAssessmentSectionAssemblyCategories(
- assessmentSection.FailureMechanismContribution.SignalingNorm,
- assessmentSection.FailureMechanismContribution.LowerLimitNorm);
-
- switch (categoryType)
- {
- case AssessmentSectionCategoryType.FactorizedSignalingNorm:
- return categories.First(c => c.Group == AssessmentSectionAssemblyCategoryGroup.A)
- .LowerBoundary;
- case AssessmentSectionCategoryType.SignalingNorm:
- return categories.First(c => c.Group == AssessmentSectionAssemblyCategoryGroup.B)
- .LowerBoundary;
- case AssessmentSectionCategoryType.LowerLimitNorm:
- return categories.First(c => c.Group == AssessmentSectionAssemblyCategoryGroup.C)
- .LowerBoundary;
- case AssessmentSectionCategoryType.FactorizedLowerLimitNorm:
- return categories.First(c => c.Group == AssessmentSectionAssemblyCategoryGroup.D)
- .LowerBoundary;
- default:
- throw new NotSupportedException();
- }
- }
-
- ///
/// Gets the relevant collection of based on the of the
/// assessment section.
///
Index: Riskeer/Common/test/Riskeer.Common.Data.Test/AssessmentSection/AssessmentSectionExtensionsTest.cs
===================================================================
diff -u -r4b889a77a0b2a44d9eadc54540334140415177c8 -rdc66d2df32013dc5dac0f0bfd07d6b474ec4a9d8
--- Riskeer/Common/test/Riskeer.Common.Data.Test/AssessmentSection/AssessmentSectionExtensionsTest.cs (.../AssessmentSectionExtensionsTest.cs) (revision 4b889a77a0b2a44d9eadc54540334140415177c8)
+++ Riskeer/Common/test/Riskeer.Common.Data.Test/AssessmentSection/AssessmentSectionExtensionsTest.cs (.../AssessmentSectionExtensionsTest.cs) (revision dc66d2df32013dc5dac0f0bfd07d6b474ec4a9d8)
@@ -20,7 +20,6 @@
// All rights reserved.
using System;
-using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
@@ -41,10 +40,10 @@
public void GetNormativeAssessmentLevel_AssessmentSectionNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate test = () => AssessmentSectionExtensions.GetNormativeAssessmentLevel(null, new TestHydraulicBoundaryLocation());
+ void Call() => AssessmentSectionExtensions.GetNormativeAssessmentLevel(null, new TestHydraulicBoundaryLocation());
// Assert
- string paramName = Assert.Throws(test).ParamName;
+ string paramName = Assert.Throws(Call).ParamName;
Assert.AreEqual("assessmentSection", paramName);
}
@@ -54,27 +53,35 @@
// Setup
const int invalidValue = 9999;
- var assessmentSection = new AssessmentSectionStub();
+ var assessmentSection = new AssessmentSectionStub
+ {
+ FailureMechanismContribution =
+ {
+ NormativeNorm = (NormType) invalidValue
+ }
+ };
- assessmentSection.FailureMechanismContribution.NormativeNorm = (NormType) invalidValue;
-
// Call
- TestDelegate test = () => assessmentSection.GetNormativeAssessmentLevel(new TestHydraulicBoundaryLocation());
+ void Call() => assessmentSection.GetNormativeAssessmentLevel(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;
+ var expectedMessage = $"The value of argument 'normType' ({invalidValue}) is invalid for Enum type '{nameof(NormType)}'.";
+ string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage).ParamName;
Assert.AreEqual("normType", parameterName);
}
[Test]
public void GetNormativeAssessmentLevel_HydraulicBoundaryLocationNull_ReturnsNaN()
{
// Setup
- var assessmentSection = new AssessmentSectionStub();
+ var assessmentSection = new AssessmentSectionStub
+ {
+ FailureMechanismContribution =
+ {
+ NormativeNorm = new Random(32).NextEnumValue()
+ }
+ };
- assessmentSection.FailureMechanismContribution.NormativeNorm = new Random(32).NextEnumValue();
-
// Call
RoundedDouble normativeAssessmentLevel = assessmentSection.GetNormativeAssessmentLevel(null);
@@ -86,10 +93,14 @@
public void GetNormativeAssessmentLevel_NoCorrespondingCalculation_ReturnsNaN()
{
// Setup
- var assessmentSection = new AssessmentSectionStub();
+ var assessmentSection = new AssessmentSectionStub
+ {
+ FailureMechanismContribution =
+ {
+ NormativeNorm = new Random(32).NextEnumValue()
+ }
+ };
- assessmentSection.FailureMechanismContribution.NormativeNorm = new Random(32).NextEnumValue();
-
// Call
RoundedDouble normativeAssessmentLevel = assessmentSection.GetNormativeAssessmentLevel(new TestHydraulicBoundaryLocation());
@@ -140,12 +151,11 @@
public void GetAssessmentLevel_AssessmentSectionNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate test = () => AssessmentSectionExtensions.GetAssessmentLevel(null,
- new TestHydraulicBoundaryLocation(),
- AssessmentSectionCategoryType.FactorizedLowerLimitNorm);
+ void Call() => AssessmentSectionExtensions.GetAssessmentLevel(null, new TestHydraulicBoundaryLocation(),
+ AssessmentSectionCategoryType.FactorizedLowerLimitNorm);
// Assert
- string paramName = Assert.Throws(test).ParamName;
+ string paramName = Assert.Throws(Call).ParamName;
Assert.AreEqual("assessmentSection", paramName);
}
@@ -158,12 +168,12 @@
var assessmentSection = new AssessmentSectionStub();
// Call
- TestDelegate test = () => assessmentSection.GetAssessmentLevel(new TestHydraulicBoundaryLocation(),
- (AssessmentSectionCategoryType) invalidValue);
+ void Call() => assessmentSection.GetAssessmentLevel(new TestHydraulicBoundaryLocation(),
+ (AssessmentSectionCategoryType) invalidValue);
// Assert
- string expectedMessage = $"The value of argument 'categoryType' ({invalidValue}) is invalid for Enum type '{nameof(AssessmentSectionCategoryType)}'.";
- string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage).ParamName;
+ var expectedMessage = $"The value of argument 'categoryType' ({invalidValue}) is invalid for Enum type '{nameof(AssessmentSectionCategoryType)}'.";
+ string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage).ParamName;
Assert.AreEqual("categoryType", parameterName);
}
@@ -236,13 +246,11 @@
public void GetHydraulicBoundaryLocationCalculation_AssessmentSectionNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate test = () => AssessmentSectionExtensions.GetHydraulicBoundaryLocationCalculation(
- null,
- new TestHydraulicBoundaryLocation(),
- AssessmentSectionCategoryType.FactorizedLowerLimitNorm);
+ void Call() => AssessmentSectionExtensions.GetHydraulicBoundaryLocationCalculation(null, new TestHydraulicBoundaryLocation(),
+ AssessmentSectionCategoryType.FactorizedLowerLimitNorm);
// Assert
- string paramName = Assert.Throws(test).ParamName;
+ string paramName = Assert.Throws(Call).ParamName;
Assert.AreEqual("assessmentSection", paramName);
}
@@ -255,13 +263,12 @@
var assessmentSection = new AssessmentSectionStub();
// Call
- TestDelegate test = () => assessmentSection.GetHydraulicBoundaryLocationCalculation(
- new TestHydraulicBoundaryLocation(),
- (AssessmentSectionCategoryType) invalidValue);
+ void Call() => assessmentSection.GetHydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation(),
+ (AssessmentSectionCategoryType) invalidValue);
// Assert
- string expectedMessage = $"The value of argument 'categoryType' ({invalidValue}) is invalid for Enum type '{nameof(AssessmentSectionCategoryType)}'.";
- string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage).ParamName;
+ var expectedMessage = $"The value of argument 'categoryType' ({invalidValue}) is invalid for Enum type '{nameof(AssessmentSectionCategoryType)}'.";
+ string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage).ParamName;
Assert.AreEqual("categoryType", parameterName);
}
@@ -317,10 +324,10 @@
public void GetNormativeHydraulicBoundaryLocationCalculation_AssessmentSectionNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate call = () => AssessmentSectionExtensions.GetNormativeHydraulicBoundaryLocationCalculation(null, new TestHydraulicBoundaryLocation());
+ void Call() => AssessmentSectionExtensions.GetNormativeHydraulicBoundaryLocationCalculation(null, new TestHydraulicBoundaryLocation());
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("assessmentSection", exception.ParamName);
}
@@ -330,16 +337,20 @@
// Setup
const int invalidValue = 9999;
- var assessmentSection = new AssessmentSectionStub();
+ var assessmentSection = new AssessmentSectionStub
+ {
+ FailureMechanismContribution =
+ {
+ NormativeNorm = (NormType) invalidValue
+ }
+ };
- assessmentSection.FailureMechanismContribution.NormativeNorm = (NormType) invalidValue;
-
// Call
- TestDelegate test = () => assessmentSection.GetNormativeHydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation());
+ void Call() => assessmentSection.GetNormativeHydraulicBoundaryLocationCalculation(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;
+ var expectedMessage = $"The value of argument 'normType' ({invalidValue}) is invalid for Enum type '{nameof(NormType)}'.";
+ string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage).ParamName;
Assert.AreEqual("normType", parameterName);
}
@@ -348,8 +359,13 @@
{
// Setup
var random = new Random(21);
- var assessmentSection = new AssessmentSectionStub();
- assessmentSection.FailureMechanismContribution.NormativeNorm = random.NextEnumValue();
+ var assessmentSection = new AssessmentSectionStub
+ {
+ FailureMechanismContribution =
+ {
+ NormativeNorm = random.NextEnumValue()
+ }
+ };
// Call
HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation = assessmentSection.GetNormativeHydraulicBoundaryLocationCalculation(null);
@@ -363,8 +379,13 @@
{
// Setup
var random = new Random(21);
- var assessmentSection = new AssessmentSectionStub();
- assessmentSection.FailureMechanismContribution.NormativeNorm = random.NextEnumValue();
+ var assessmentSection = new AssessmentSectionStub
+ {
+ FailureMechanismContribution =
+ {
+ NormativeNorm = random.NextEnumValue()
+ }
+ };
// Call
HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation =
@@ -393,84 +414,6 @@
Assert.AreSame(calculation, normativeHydraulicBoundaryLocationCalculation);
}
- [Test]
- public void GetNorm_AssessmentSectionNull_ThrowsArgumentNullException()
- {
- // Call
- TestDelegate test = () => AssessmentSectionExtensions.GetNorm(null,
- AssessmentSectionCategoryType.FactorizedLowerLimitNorm);
-
- // Assert
- string paramName = Assert.Throws(test).ParamName;
- Assert.AreEqual("assessmentSection", paramName);
- }
-
- [Test]
- public void GetNorm_InvalidAssessmentSectionCategoryType_ThrowsInvalidEnumArgumentException()
- {
- // Setup
- const int invalidValue = 9999;
-
- var assessmentSection = new AssessmentSectionStub();
-
- // Call
- TestDelegate test = () => assessmentSection.GetNorm((AssessmentSectionCategoryType) invalidValue);
-
- // Assert
- string expectedMessage = $"The value of argument 'categoryType' ({invalidValue}) is invalid for Enum type '{nameof(AssessmentSectionCategoryType)}'.";
- string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage).ParamName;
- Assert.AreEqual("categoryType", parameterName);
- }
-
- [Test]
- [TestCaseSource(nameof(GetNormConfigurationPerAssessmentSectionCategoryType))]
- public void GetNorm_AssessmentSectionWithNormConfiguration_ReturnsCorrespondingNorm(
- IAssessmentSection assessmentSection,
- AssessmentSectionCategoryType categoryType,
- double expectedNorm)
- {
- // Call
- double norm = assessmentSection.GetNorm(categoryType);
-
- // Assert
- Assert.AreEqual(expectedNorm, norm);
- }
-
- private static IEnumerable GetNormConfigurationPerAssessmentSectionCategoryType()
- {
- const double signalingNorm = 0.002;
- const double lowerLimitNorm = 0.005;
-
- var assessmentSection = new AssessmentSectionStub
- {
- FailureMechanismContribution =
- {
- LowerLimitNorm = lowerLimitNorm,
- SignalingNorm = signalingNorm
- }
- };
-
- yield return new TestCaseData(
- assessmentSection,
- AssessmentSectionCategoryType.FactorizedSignalingNorm,
- signalingNorm / 30);
-
- yield return new TestCaseData(
- assessmentSection,
- AssessmentSectionCategoryType.SignalingNorm,
- signalingNorm);
-
- yield return new TestCaseData(
- assessmentSection,
- AssessmentSectionCategoryType.LowerLimitNorm,
- lowerLimitNorm);
-
- yield return new TestCaseData(
- assessmentSection,
- AssessmentSectionCategoryType.FactorizedLowerLimitNorm,
- lowerLimitNorm * 30);
- }
-
private static IEnumerable GetNormativeHydraulicBoundaryLocationCalculationPerNormType()
{
var assessmentSection = new AssessmentSectionStub();
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs
===================================================================
diff -u -r4b2a068d26aeaa1251bfd9f1716efafdd12d54d4 -rdc66d2df32013dc5dac0f0bfd07d6b474ec4a9d8
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 4b2a068d26aeaa1251bfd9f1716efafdd12d54d4)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision dc66d2df32013dc5dac0f0bfd07d6b474ec4a9d8)
@@ -2318,10 +2318,10 @@
{
new WaterLevelCalculationsForNormTargetProbabilityContext(context.AssessmentSection.WaterLevelCalculationsForLowerLimitNorm,
context.AssessmentSection,
- () => context.AssessmentSection.GetNorm(AssessmentSectionCategoryType.LowerLimitNorm)),
+ () => context.AssessmentSection.FailureMechanismContribution.LowerLimitNorm),
new WaterLevelCalculationsForNormTargetProbabilityContext(context.AssessmentSection.WaterLevelCalculationsForSignalingNorm,
context.AssessmentSection,
- () => context.AssessmentSection.GetNorm(AssessmentSectionCategoryType.SignalingNorm))
+ () => context.AssessmentSection.FailureMechanismContribution.SignalingNorm)
};
}