Index: Ringtoets/Common/src/Ringtoets.Common.Data/AssemblyTool/AssemblyCategoriesInputFactory.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Data/AssemblyTool/AssemblyCategoriesInputFactory.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/AssemblyTool/AssemblyCategoriesInputFactory.cs (revision 283def2fc4e1161789c176aa8f8e9e8bb4af3e4b)
@@ -0,0 +1,63 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+
+namespace Ringtoets.Common.Data.AssemblyTool
+{
+ ///
+ /// Factory for creating instances of .
+ ///
+ public static class AssemblyCategoriesInputFactory
+ {
+ ///
+ /// Creates an instance of .
+ ///
+ /// The 'N' parameter of the failure mechanism
+ /// used to factor in the 'length effect'.
+ /// The failure mechanism to create the input for.
+ /// The assessment section to create the input for.
+ /// A .
+ /// Thrown when any parameter is null.
+ public static AssemblyCategoriesInput CreateAssemblyCategoriesInput(double n,
+ IFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ return new AssemblyCategoriesInput(n,
+ failureMechanism.Contribution,
+ assessmentSection.FailureMechanismContribution.SignalingNorm,
+ assessmentSection.FailureMechanismContribution.LowerLimitNorm);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/AssemblyTool/AssemblyCategoriesInputFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/AssemblyTool/AssemblyCategoriesInputFactoryTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/AssemblyTool/AssemblyCategoriesInputFactoryTest.cs (revision 283def2fc4e1161789c176aa8f8e9e8bb4af3e4b)
@@ -0,0 +1,93 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.Common.Data.AssemblyTool;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+
+namespace Ringtoets.Common.Data.Test.AssemblyTool
+{
+ [TestFixture]
+ public class AssemblyCategoriesInputFactoryTest
+ {
+ [Test]
+ public void CreateAssemblyCategoriesInput_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => AssemblyCategoriesInputFactory.CreateAssemblyCategoriesInput(new Random(39).NextDouble(),
+ null,
+ assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateAssemblyCategoriesInput_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var failureMechanism = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => AssemblyCategoriesInputFactory.CreateAssemblyCategoriesInput(new Random(39).NextDouble(),
+ failureMechanism,
+ null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateAssemblyCategoriesInput_WithValidInput_ReturnsExpectedAssemblyCategoriesInput()
+ {
+ // Setup
+ var random = new Random(39);
+ double n = random.NextDouble();
+ var failureMechanism = new TestFailureMechanism();
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ AssemblyCategoriesInput assemblyCategoriesInput = AssemblyCategoriesInputFactory.CreateAssemblyCategoriesInput(n, failureMechanism, assessmentSection);
+
+ // Assert
+ Assert.AreEqual(n, assemblyCategoriesInput.N);
+ Assert.AreEqual(failureMechanism.Contribution / 100, assemblyCategoriesInput.FailureMechanismContribution);
+ Assert.AreEqual(assessmentSection.FailureMechanismContribution.SignalingNorm, assemblyCategoriesInput.SignalingNorm);
+ Assert.AreEqual(assessmentSection.FailureMechanismContribution.LowerLimitNorm, assemblyCategoriesInput.LowerLimitNorm);
+ }
+ }
+}
\ No newline at end of file