Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/DuneErosionFailureMechanismExtensions.cs =================================================================== diff -u -r861341a7835c17ca6309ff1b6e0b8fe2269b5c0f -r32061d48745c5325becd9adac3118d976587b3b6 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/DuneErosionFailureMechanismExtensions.cs (.../DuneErosionFailureMechanismExtensions.cs) (revision 861341a7835c17ca6309ff1b6e0b8fe2269b5c0f) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/DuneErosionFailureMechanismExtensions.cs (.../DuneErosionFailureMechanismExtensions.cs) (revision 32061d48745c5325becd9adac3118d976587b3b6) @@ -23,7 +23,9 @@ using System.Collections.Generic; using System.Linq; using Core.Common.Base.Geometry; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.DuneErosion.Data.Properties; namespace Ringtoets.DuneErosion.Data { @@ -64,5 +66,35 @@ } } } + + /// + /// Gets the norm which is needed in the calculations within . + /// + /// The to get the failure mechanism norm for. + /// The which contains the assessment section norm. + /// The value of the failure mechanism norm. + /// Thrown when any parameter is null. + /// Thrown when has no (0) contribution. + public static double GetMechanismSpecificNorm(this DuneErosionFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } + if (assessmentSection == null) + { + throw new ArgumentNullException("assessmentSection"); + } + + if (Math.Abs(failureMechanism.Contribution) < 1e-6) + { + throw new ArgumentException(Resources.DuneErosionFailureMechanismExtensions_GetMechanismSpecificNorm_Contribution_is_zero); + } + + return 2.15*(failureMechanism.Contribution/100) + *assessmentSection.FailureMechanismContribution.Norm + /failureMechanism.GeneralInput.N; + } } } \ No newline at end of file Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Properties/Resources.Designer.cs =================================================================== diff -u -r9ea9915bf83c70b481d4c58af0ae7e5866218766 -r32061d48745c5325becd9adac3118d976587b3b6 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 9ea9915bf83c70b481d4c58af0ae7e5866218766) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 32061d48745c5325becd9adac3118d976587b3b6) @@ -98,5 +98,15 @@ return ResourceManager.GetString("DuneErosionFailureMechanism_DisplayName", resourceCulture); } } + + /// + /// Looks up a localized string similar to De bijdrage van dit toetsspoor is nul. Daardoor kunnen de berekeningen niet worden uitgevoerd.. + /// + public static string DuneErosionFailureMechanismExtensions_GetMechanismSpecificNorm_Contribution_is_zero { + get { + return ResourceManager.GetString("DuneErosionFailureMechanismExtensions_GetMechanismSpecificNorm_Contribution_is_ze" + + "ro", resourceCulture); + } + } } } Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Properties/Resources.resx =================================================================== diff -u -ra4cd22ab000aa81906e43b5fd2898e52fee0e366 -r32061d48745c5325becd9adac3118d976587b3b6 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Properties/Resources.resx (.../Resources.resx) (revision a4cd22ab000aa81906e43b5fd2898e52fee0e366) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Properties/Resources.resx (.../Resources.resx) (revision 32061d48745c5325becd9adac3118d976587b3b6) @@ -123,4 +123,7 @@ Duinwaterkering - Duinafslag + + De bijdrage van dit toetsspoor is nul. Daardoor kunnen de berekeningen niet worden uitgevoerd. + \ No newline at end of file Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Ringtoets.DuneErosion.Data.csproj =================================================================== diff -u -rff3476b4646da757e0ec892b069b31336cbd520e -r32061d48745c5325becd9adac3118d976587b3b6 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Ringtoets.DuneErosion.Data.csproj (.../Ringtoets.DuneErosion.Data.csproj) (revision ff3476b4646da757e0ec892b069b31336cbd520e) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Ringtoets.DuneErosion.Data.csproj (.../Ringtoets.DuneErosion.Data.csproj) (revision 32061d48745c5325becd9adac3118d976587b3b6) @@ -72,6 +72,7 @@ PublicResXFileCodeGenerator Resources.Designer.cs + Designer Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/DuneErosionFailureMechanismExtensionsTest.cs =================================================================== diff -u -r861341a7835c17ca6309ff1b6e0b8fe2269b5c0f -r32061d48745c5325becd9adac3118d976587b3b6 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/DuneErosionFailureMechanismExtensionsTest.cs (.../DuneErosionFailureMechanismExtensionsTest.cs) (revision 861341a7835c17ca6309ff1b6e0b8fe2269b5c0f) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/DuneErosionFailureMechanismExtensionsTest.cs (.../DuneErosionFailureMechanismExtensionsTest.cs) (revision 32061d48745c5325becd9adac3118d976587b3b6) @@ -21,7 +21,11 @@ using System; using System.Linq; +using Core.Common.TestUtil; using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.DuneErosion.Data.TestUtil; @@ -105,5 +109,97 @@ // Assert CollectionAssert.IsEmpty(failureMechanism.DuneLocations); } + + [Test] + public void GetMechanismSpecificNorm_FailureMechanismNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => DuneErosionFailureMechanismExtensions.GetMechanismSpecificNorm(null, assessmentSection); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void GetMechanismSpecificNorm_AssessmentSectionNull_ThrowArgumentNullException() + { + // Setup + var failureMechanism = new DuneErosionFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.GetMechanismSpecificNorm(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void GetMechanismSpecificNorm_WithZeroContributionForFailureMechanism_ThrowsArgumentException() + { + // Setup + var failureMechanism = new DuneErosionFailureMechanism + { + Contribution = 0 + }; + + var mocks = new MockRepository(); + var assessmentSection = mocks.StrictMock(); + assessmentSection.Stub(a => a.GetFailureMechanisms()).Return(new[] + { + failureMechanism + }); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(new[] + { + failureMechanism + }, 1, 1.0 / 300)); + mocks.ReplayAll(); + + // Call + TestDelegate action = () => failureMechanism.GetMechanismSpecificNorm(assessmentSection); + + // Assert + const string expectedMessage = "De bijdrage van dit toetsspoor is nul. Daardoor kunnen de berekeningen niet worden uitgevoerd."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(action, expectedMessage); + mocks.VerifyAll(); + } + + [Test] + public void GetMechanismSpecificNorm_WithValidData_ReturnMechanismSpecificNorm() + { + // Setup + const double norm = 1.0 / 200; + const double contribution = 10; + var failureMechanism = new DuneErosionFailureMechanism + { + Contribution = contribution + }; + + var mocks = new MockRepository(); + var assessmentSection = mocks.StrictMock(); + assessmentSection.Stub(a => a.GetFailureMechanisms()).Return(new[] + { + failureMechanism + }); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(new[] + { + failureMechanism + }, 1, norm)); + mocks.ReplayAll(); + + // Call + double mechanismSpecificNorm = failureMechanism.GetMechanismSpecificNorm(assessmentSection); + + // Assert + Assert.AreEqual(0.0005375, mechanismSpecificNorm); + mocks.VerifyAll(); + } } } \ No newline at end of file Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/Ringtoets.DuneErosion.Data.Test.csproj =================================================================== diff -u -rff3476b4646da757e0ec892b069b31336cbd520e -r32061d48745c5325becd9adac3118d976587b3b6 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/Ringtoets.DuneErosion.Data.Test.csproj (.../Ringtoets.DuneErosion.Data.Test.csproj) (revision ff3476b4646da757e0ec892b069b31336cbd520e) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/Ringtoets.DuneErosion.Data.Test.csproj (.../Ringtoets.DuneErosion.Data.Test.csproj) (revision 32061d48745c5325becd9adac3118d976587b3b6) @@ -42,6 +42,10 @@ ..\..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll True + + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + True + @@ -67,6 +71,10 @@ {3BBFD65B-B277-4E50-AE6D-BD24C3434609} Core.Common.Base + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {D4200F43-3F72-4F42-AF0A-8CED416A38EC} Ringtoets.Common.Data Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/packages.config =================================================================== diff -u -ra4cd22ab000aa81906e43b5fd2898e52fee0e366 -r32061d48745c5325becd9adac3118d976587b3b6 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/packages.config (.../packages.config) (revision a4cd22ab000aa81906e43b5fd2898e52fee0e366) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/packages.config (.../packages.config) (revision 32061d48745c5325becd9adac3118d976587b3b6) @@ -1,4 +1,5 @@ - - + \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismExtensions.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r32061d48745c5325becd9adac3118d976587b3b6 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismExtensions.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensions.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismExtensions.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensions.cs) (revision 32061d48745c5325becd9adac3118d976587b3b6) @@ -59,7 +59,7 @@ /// Gets the norm which is needed in the calculations within . /// /// The to get the failure mechanism norm for. - /// The which contains the assessment section norm + /// The which contains the assessment section norm. /// The value of the failure mechanism norm. /// Thrown when is null. /// Thrown when has no (0) contribution. Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r32061d48745c5325becd9adac3118d976587b3b6 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs (.../GrassCoverErosionOutwardsFailureMechanismExtensionsTest.cs) (revision 32061d48745c5325becd9adac3118d976587b3b6) @@ -128,6 +128,7 @@ // Assert Assert.AreEqual(0.00025, mechanismSpecificNorm); + mocks.VerifyAll(); } [Test] @@ -156,6 +157,7 @@ // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(action, "De bijdrage van dit toetsspoor is nul. Daardoor is de doorsnede-eis onbepaald en kunnen de berekeningen niet worden uitgevoerd."); + mocks.VerifyAll(); } } } \ No newline at end of file