Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,287 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.ClosingStructures.Data +{ + /// + /// Factory for assembling assembly results for a closing structures failure mechanism. + /// + public static class ClosingStructuresFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleSimpleAssessment( + ClosingStructuresFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleDetailedAssessment( + ClosingStructuresFailureMechanismSectionResult failureMechanismSectionResult, + ClosingStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult, + failureMechanismSectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleTailorMadeAssessment( + ClosingStructuresFailureMechanismSectionResult failureMechanismSectionResult, + ClosingStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult, + failureMechanismSectionResult.TailorMadeAssessmentProbability, + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleCombinedAssessment( + ClosingStructuresFailureMechanismSectionResult failureMechanismSectionResult, + ClosingStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanismSectionAssembly simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssembly detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult, failureMechanism, assessmentSection); + FailureMechanismSectionAssembly tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult, failureMechanism, assessmentSection); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism to assemble for. + /// The the failure mechanism belongs to. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssembly AssembleFailureMechanism( + ClosingStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + bool considerManualAssembly = true) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator sectionCalculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + AssemblyCategoriesInput assemblyCategoriesInput = CreateAssemblyCategoriesInput(failureMechanism, assessmentSection); + var sectionAssemblies = new List(); + + try + { + foreach (ClosingStructuresFailureMechanismSectionResult sectionResult in failureMechanism.SectionResults) + { + if (sectionResult.UseManualAssemblyProbability && considerManualAssembly) + { + sectionAssemblies.Add(sectionCalculator.AssembleDetailedAssessment( + DetailedAssessmentProbabilityOnlyResultType.Probability, + sectionResult.ManualAssemblyProbability, + assemblyCategoriesInput)); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult, + failureMechanism, + assessmentSection)); + } + } + + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + return calculator.Assemble(sectionAssemblies, assemblyCategoriesInput); + } + catch (Exception e) when (e is FailureMechanismAssemblyCalculatorException || e is FailureMechanismSectionAssemblyCalculatorException) + { + throw new AssemblyException(e.Message, e); + } + } + + private static AssemblyCategoriesInput CreateAssemblyCategoriesInput(ClosingStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + return new AssemblyCategoriesInput(failureMechanism.GeneralInput.N, + failureMechanism.Contribution, + assessmentSection.FailureMechanismContribution.SignalingNorm, + assessmentSection.FailureMechanismContribution.LowerLimitNorm); + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/Ringtoets.ClosingStructures.Data.csproj =================================================================== diff -u -r739752c5cc7ed800dacf74e12221c227183ddc6f -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/Ringtoets.ClosingStructures.Data.csproj (.../Ringtoets.ClosingStructures.Data.csproj) (revision 739752c5cc7ed800dacf74e12221c227183ddc6f) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/Ringtoets.ClosingStructures.Data.csproj (.../Ringtoets.ClosingStructures.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -15,7 +15,7 @@ - + Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismResultView.cs =================================================================== diff -u -r03f260e74af2da4f651a4abad32e5416999c814a -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismResultView.cs (.../ClosingStructuresFailureMechanismResultView.cs) (revision 03f260e74af2da4f651a4abad32e5416999c814a) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismResultView.cs (.../ClosingStructuresFailureMechanismResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -75,7 +75,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultWithProbabilityControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(ClosingStructuresFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); // The concat is needed to observe the input of calculations in child groups. calculationInputObserver = new RecursiveObserver( Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -r845bc0316bfb8173d53a1d002686fc9a6a631ee1 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs (.../ClosingStructuresFailureMechanismSectionResultRow.cs) (revision 845bc0316bfb8173d53a1d002686fc9a6a631ee1) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs (.../ClosingStructuresFailureMechanismSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -362,7 +362,7 @@ { try { - simpleAssemblyCategoryGroup = ClosingStructuresFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; + simpleAssemblyCategoryGroup = ClosingStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; } catch (AssemblyException e) { @@ -375,7 +375,7 @@ { try { - detailedAssemblyCategoryGroup = ClosingStructuresFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment( + detailedAssemblyCategoryGroup = ClosingStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -391,7 +391,7 @@ { try { - tailorMadeAssemblyCategoryGroup = ClosingStructuresFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment( + tailorMadeAssemblyCategoryGroup = ClosingStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -408,7 +408,7 @@ try { FailureMechanismSectionAssembly combinedAssembly = - ClosingStructuresFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + ClosingStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult, failureMechanism, assessmentSection); Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,836 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.Data.TestUtil; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.ClosingStructures.Data.Test +{ + [TestFixture] + public class ClosingStructuresFailureMechanismAssemblyFactoryTest + { + private static void AssertAssemblyCategoriesInput(IAssessmentSection assessmentSection, + ClosingStructuresFailureMechanism failureMechanism, + AssemblyCategoriesInput assemblyCategoriesInput) + { + Assert.AreEqual(assessmentSection.FailureMechanismContribution.SignalingNorm, assemblyCategoriesInput.SignalingNorm); + Assert.AreEqual(assessmentSection.FailureMechanismContribution.LowerLimitNorm, assemblyCategoriesInput.LowerLimitNorm); + Assert.AreEqual(failureMechanism.Contribution, assemblyCategoriesInput.FailureMechanismContribution); + Assert.AreEqual(failureMechanism.GeneralInput.N, assemblyCategoriesInput.N); + } + + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + ClosingStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + ClosingStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + null, + new ClosingStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new ClosingStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + DetailedAssessmentResult = new Random(21).NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + ClosingStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentProbabilityOnlyResultInput); + Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), + calculator.DetailedAssessmentProbabilityInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + ClosingStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Tailor made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + null, + new ClosingStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new ClosingStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + ClosingStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentProbability, calculator.TailorMadeAssessmentProbabilityInput); + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentProbabilityCalculationResultInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + ClosingStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.TailorMadeAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null, + new ClosingStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new ClosingStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + ClosingStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedSimpleAssembly = ClosingStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssembly expectedDetailedAssembly = ClosingStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + FailureMechanismSectionAssembly expectedTailorMadeAssembly = ClosingStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + AssemblyToolTestHelper.AssertAreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + ClosingStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.CombinedAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + new ClosingStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + new ClosingStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = ClosingStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + ClosingStructuresFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = ClosingStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + ClosingStructuresFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection, + false); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = ClosingStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssembly actualOutput = + ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + Assert.AreSame(calculator.FailureMechanismAssemblyOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj =================================================================== diff -u -r344e4eb60e8d9343ad55ad44291d2452bb9c3ae7 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj (.../Ringtoets.ClosingStructures.Data.Test.csproj) (revision 344e4eb60e8d9343ad55ad44291d2452bb9c3ae7) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj (.../Ringtoets.ClosingStructures.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -21,7 +21,7 @@ - + Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/DuneErosionFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/DuneErosionFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/DuneErosionFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,219 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; + +namespace Ringtoets.DuneErosion.Data +{ + /// + /// Factory for creating assembly results for a dune erosion failure mechanism. + /// + public static class DuneErosionFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results based on . + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment(DuneErosionFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment results. + /// + /// The failure mechanism section result to assemble the + /// detailed assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment( + DuneErosionFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment(failureMechanismSectionResult.DetailedAssessmentResultForFactorizedSignalingNorm, + failureMechanismSectionResult.DetailedAssessmentResultForSignalingNorm, + failureMechanismSectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, + failureMechanismSectionResult.DetailedAssessmentResultForLowerLimitNorm, + failureMechanismSectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment results. + /// + /// The failure mechanism section result to assemble the + /// tailor made assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + DuneErosionFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment(failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assessment results. + /// + /// The failure mechanism section result to assemble the + /// combined assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + DuneErosionFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (DuneErosionFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/DuneErosionFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Ringtoets.DuneErosion.Data.csproj =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Ringtoets.DuneErosion.Data.csproj (.../Ringtoets.DuneErosion.Data.csproj) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Data/Ringtoets.DuneErosion.Data.csproj (.../Ringtoets.DuneErosion.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -11,7 +11,7 @@ - + Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismResultView.cs =================================================================== diff -u -r22119e7519787dafd57e2e42b1ea37699d1d4bf3 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismResultView.cs (.../DuneErosionFailureMechanismResultView.cs) (revision 22119e7519787dafd57e2e42b1ea37699d1d4bf3) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismResultView.cs (.../DuneErosionFailureMechanismResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -58,7 +58,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(DuneErosionFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(DuneErosionFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override DuneErosionSectionResultRow CreateFailureMechanismSectionResultRow(DuneErosionFailureMechanismSectionResult sectionResult) Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionSectionResultRow.cs =================================================================== diff -u -r845bc0316bfb8173d53a1d002686fc9a6a631ee1 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionSectionResultRow.cs (.../DuneErosionSectionResultRow.cs) (revision 845bc0316bfb8173d53a1d002686fc9a6a631ee1) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionSectionResultRow.cs (.../DuneErosionSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -357,7 +357,7 @@ { try { - simpleAssemblyCategoryGroup = DuneErosionFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = DuneErosionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -370,7 +370,7 @@ { try { - detailedAssemblyCategoryGroup = DuneErosionFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment(SectionResult); + detailedAssemblyCategoryGroup = DuneErosionFailureMechanismAssemblyFactory.AssembleDetailedAssessment(SectionResult); } catch (AssemblyException e) { @@ -383,7 +383,7 @@ { try { - tailorMadeAssemblyCategoryGroup = DuneErosionFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = DuneErosionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -396,7 +396,7 @@ { try { - combinedAssemblyCategoryGroup = DuneErosionFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + combinedAssemblyCategoryGroup = DuneErosionFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult); } catch (AssemblyException e) Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/DuneErosionFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/DuneErosionFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/DuneErosionFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,526 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.DuneErosion.Data.Test +{ + [TestFixture] + public class DuneErosionFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new DuneErosionFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + DuneErosionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentValidityOnlyInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new DuneErosionFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + DuneErosionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new DuneErosionFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleDetailedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new DuneErosionFailureMechanismSectionResult(failureMechanismSection) + { + DetailedAssessmentResultForFactorizedSignalingNorm = random.NextEnumValue(), + DetailedAssessmentResultForSignalingNorm = random.NextEnumValue(), + DetailedAssessmentResultForMechanismSpecificLowerLimitNorm = random.NextEnumValue(), + DetailedAssessmentResultForLowerLimitNorm = random.NextEnumValue(), + DetailedAssessmentResultForFactorizedLowerLimitNorm = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + DuneErosionFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedSignalingNorm, calculator.DetailedAssessmentResultForFactorizedSignalingNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForSignalingNorm, calculator.DetailedAssessmentResultForSignalingNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, calculator.DetailedAssessmentResultForMechanismSpecificLowerLimitNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForLowerLimitNorm, calculator.DetailedAssessmentResultForLowerLimitNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm, calculator.DetailedAssessmentResultForFactorizedLowerLimitNormInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new DuneErosionFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + DuneErosionFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.DetailedAssessmentAssemblyGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new DuneErosionFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new DuneErosionFailureMechanismSectionResult(failureMechanismSection) + { + TailorMadeAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + DuneErosionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentGroupInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new DuneErosionFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + DuneErosionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.TailorMadeAssemblyCategoryOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new DuneErosionFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new DuneErosionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + DuneErosionFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = DuneErosionFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly = DuneErosionFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = DuneErosionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new DuneErosionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + DuneErosionFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new DuneErosionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new DuneErosionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + DuneErosionFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + DuneErosionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new DuneErosionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + DuneErosionFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new DuneErosionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + DuneErosionFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + DuneErosionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + DuneErosionFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => DuneErosionFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/DuneErosionFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/Ringtoets.DuneErosion.Data.Test.csproj =================================================================== diff -u -r59527a5120b5c6c1239449c823ea6b0f76000df6 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/Ringtoets.DuneErosion.Data.Test.csproj (.../Ringtoets.DuneErosion.Data.Test.csproj) (revision 59527a5120b5c6c1239449c823ea6b0f76000df6) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Data.Test/Ringtoets.DuneErosion.Data.Test.csproj (.../Ringtoets.DuneErosion.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -15,7 +15,7 @@ - + Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,289 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.GrassCoverErosionInwards.Data +{ + /// + /// Factory for assembling assembly results for a grass cover erosion inwards failure mechanism. + /// + public static class GrassCoverErosionInwardsFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleSimpleAssessment( + GrassCoverErosionInwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleDetailedAssessment( + GrassCoverErosionInwardsFailureMechanismSectionResult failureMechanismSectionResult, + GrassCoverErosionInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult, + failureMechanismSectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleTailorMadeAssessment( + GrassCoverErosionInwardsFailureMechanismSectionResult failureMechanismSectionResult, + GrassCoverErosionInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult, + failureMechanismSectionResult.TailorMadeAssessmentProbability, + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleCombinedAssessment( + GrassCoverErosionInwardsFailureMechanismSectionResult failureMechanismSectionResult, + GrassCoverErosionInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanismSectionAssembly simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssembly detailedAssembly = AssembleDetailedAssessment( + failureMechanismSectionResult, failureMechanism, assessmentSection); + FailureMechanismSectionAssembly tailorMadeAssembly = AssembleTailorMadeAssessment( + failureMechanismSectionResult, failureMechanism, assessmentSection); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism to assemble for. + /// The the failure mechanism belongs to. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssembly AssembleFailureMechanism( + GrassCoverErosionInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + bool considerManualAssembly = true) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator sectionCalculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + AssemblyCategoriesInput assemblyCategoriesInput = CreateAssemblyCategoriesInput(failureMechanism, assessmentSection); + var sectionAssemblies = new List(); + + try + { + foreach (GrassCoverErosionInwardsFailureMechanismSectionResult sectionResult in failureMechanism.SectionResults) + { + if (sectionResult.UseManualAssemblyProbability && considerManualAssembly) + { + sectionAssemblies.Add(sectionCalculator.AssembleDetailedAssessment( + DetailedAssessmentProbabilityOnlyResultType.Probability, + sectionResult.ManualAssemblyProbability, + assemblyCategoriesInput)); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult, + failureMechanism, + assessmentSection)); + } + } + + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + return calculator.Assemble(sectionAssemblies, assemblyCategoriesInput); + } + catch (Exception e) when (e is FailureMechanismAssemblyCalculatorException || e is FailureMechanismSectionAssemblyCalculatorException) + { + throw new AssemblyException(e.Message, e); + } + } + + private static AssemblyCategoriesInput CreateAssemblyCategoriesInput(GrassCoverErosionInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + return new AssemblyCategoriesInput(failureMechanism.GeneralInput.N, + failureMechanism.Contribution, + assessmentSection.FailureMechanismContribution.SignalingNorm, + assessmentSection.FailureMechanismContribution.LowerLimitNorm); + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Ringtoets.GrassCoverErosionInwards.Data.csproj =================================================================== diff -u -r739752c5cc7ed800dacf74e12221c227183ddc6f -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Ringtoets.GrassCoverErosionInwards.Data.csproj (.../Ringtoets.GrassCoverErosionInwards.Data.csproj) (revision 739752c5cc7ed800dacf74e12221c227183ddc6f) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Ringtoets.GrassCoverErosionInwards.Data.csproj (.../Ringtoets.GrassCoverErosionInwards.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -11,7 +11,7 @@ - + Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs =================================================================== diff -u -r03f260e74af2da4f651a4abad32e5416999c814a -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision 03f260e74af2da4f651a4abad32e5416999c814a) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -74,7 +74,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultWithProbabilityControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(GrassCoverErosionInwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); // The concat is needed to observe the input of calculations in child groups. calculationInputObserver = new RecursiveObserver( Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs =================================================================== diff -u -r4994cf24768a7b54149e65713433dc4543ace82c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs) (revision 4994cf24768a7b54149e65713433dc4543ace82c) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -363,7 +363,7 @@ { try { - simpleAssemblyCategoryGroup = GrassCoverErosionInwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; + simpleAssemblyCategoryGroup = GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; } catch (AssemblyException e) { @@ -376,7 +376,7 @@ { try { - detailedAssemblyCategoryGroup = GrassCoverErosionInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment( + detailedAssemblyCategoryGroup = GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -392,7 +392,7 @@ { try { - tailorMadeAssemblyCategoryGroup = GrassCoverErosionInwardsFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment( + tailorMadeAssemblyCategoryGroup = GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -409,7 +409,7 @@ try { FailureMechanismSectionAssembly combinedAssembly = - GrassCoverErosionInwardsFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult, failureMechanism, assessmentSection); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,837 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.Data.TestUtil; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.GrassCoverErosionInwards.Data.Test +{ + [TestFixture] + public class GrassCoverErosionInwardsFailureMechanismAssemblyFactoryTest + { + private static void AssertAssemblyCategoriesInput(IAssessmentSection assessmentSection, + GrassCoverErosionInwardsFailureMechanism failureMechanism, + AssemblyCategoriesInput assemblyCategoriesInput) + { + Assert.AreEqual(assessmentSection.FailureMechanismContribution.SignalingNorm, assemblyCategoriesInput.SignalingNorm); + Assert.AreEqual(assessmentSection.FailureMechanismContribution.LowerLimitNorm, assemblyCategoriesInput.LowerLimitNorm); + Assert.AreEqual(failureMechanism.Contribution, assemblyCategoriesInput.FailureMechanismContribution); + Assert.AreEqual(failureMechanism.GeneralInput.N, assemblyCategoriesInput.N); + } + + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentValidityOnlyInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + null, + new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new GrassCoverErosionInwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + DetailedAssessmentResult = new Random(39).NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), + calculator.DetailedAssessmentProbabilityInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentProbabilityOnlyResultInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + null, + new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new GrassCoverErosionInwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentProbability, calculator.TailorMadeAssessmentProbabilityInput); + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentProbabilityCalculationResultInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.TailorMadeAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null, + new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new GrassCoverErosionInwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedSimpleAssembly = GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssembly expectedDetailedAssembly = GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + FailureMechanismSectionAssembly expectedTailorMadeAssembly = GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + AssemblyToolTestHelper.AssertAreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.CombinedAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + new GrassCoverErosionInwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + GrassCoverErosionInwardsFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + GrassCoverErosionInwardsFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection, + false); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssembly actualOutput = + GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + Assert.AreSame(calculator.FailureMechanismAssemblyOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/Ringtoets.GrassCoverErosionInwards.Data.Test.csproj =================================================================== diff -u -rb29487c198d87b176783f2396c2b59cd76b9f246 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/Ringtoets.GrassCoverErosionInwards.Data.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Data.Test.csproj) (revision b29487c198d87b176783f2396c2b59cd76b9f246) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/Ringtoets.GrassCoverErosionInwards.Data.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -19,7 +19,7 @@ - + Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,220 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; + +namespace Ringtoets.GrassCoverErosionOutwards.Data +{ + /// + /// Factory for creating assembly results for a grass cover erosion outwards failure mechanism. + /// + public static class GrassCoverErosionOutwardsFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + GrassCoverErosionOutwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment results. + /// + /// The failure mechanism section result to assemble the + /// detailed assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment( + GrassCoverErosionOutwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment(failureMechanismSectionResult.DetailedAssessmentResultForFactorizedSignalingNorm, + failureMechanismSectionResult.DetailedAssessmentResultForSignalingNorm, + failureMechanismSectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, + failureMechanismSectionResult.DetailedAssessmentResultForLowerLimitNorm, + failureMechanismSectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment results. + /// + /// The failure mechanism section result to assemble the + /// tailor made assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + GrassCoverErosionOutwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment(failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assessment results. + /// + /// The failure mechanism section result to assemble the + /// combined assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + GrassCoverErosionOutwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (GrassCoverErosionOutwardsFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/Ringtoets.GrassCoverErosionOutwards.Data.csproj =================================================================== diff -u -r015eb3822c4c4d03e957ab676e5dc4428c46f1eb -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/Ringtoets.GrassCoverErosionOutwards.Data.csproj (.../Ringtoets.GrassCoverErosionOutwards.Data.csproj) (revision 015eb3822c4c4d03e957ab676e5dc4428c46f1eb) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/Ringtoets.GrassCoverErosionOutwards.Data.csproj (.../Ringtoets.GrassCoverErosionOutwards.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -12,7 +12,7 @@ - + Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs =================================================================== diff -u -rb48d97aa03e7e823bf419d0ea2ffa4b09e215577 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs (.../GrassCoverErosionOutwardsFailureMechanismResultView.cs) (revision b48d97aa03e7e823bf419d0ea2ffa4b09e215577) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs (.../GrassCoverErosionOutwardsFailureMechanismResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -58,7 +58,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override GrassCoverErosionOutwardsFailureMechanismSectionResultRow CreateFailureMechanismSectionResultRow(GrassCoverErosionOutwardsFailureMechanismSectionResult sectionResult) Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs =================================================================== diff -u -r6bfd88d43db177e5425a69c22dfd9070e8520898 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs (.../GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs) (revision 6bfd88d43db177e5425a69c22dfd9070e8520898) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs (.../GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -357,7 +357,7 @@ { try { - simpleAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -370,7 +370,7 @@ { try { - detailedAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment(SectionResult); + detailedAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(SectionResult); } catch (AssemblyException e) { @@ -383,7 +383,7 @@ { try { - tailorMadeAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -396,7 +396,7 @@ { try { - combinedAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + combinedAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult); } catch (AssemblyException e) Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,526 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.GrassCoverErosionOutwards.Data.Test +{ + [TestFixture] + public class GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(failureMechanismSection) + { + DetailedAssessmentResultForFactorizedSignalingNorm = random.NextEnumValue(), + DetailedAssessmentResultForSignalingNorm = random.NextEnumValue(), + DetailedAssessmentResultForMechanismSpecificLowerLimitNorm = random.NextEnumValue(), + DetailedAssessmentResultForLowerLimitNorm = random.NextEnumValue(), + DetailedAssessmentResultForFactorizedLowerLimitNorm = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedSignalingNorm, calculator.DetailedAssessmentResultForFactorizedSignalingNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForSignalingNorm, calculator.DetailedAssessmentResultForSignalingNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, calculator.DetailedAssessmentResultForMechanismSpecificLowerLimitNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForLowerLimitNorm, calculator.DetailedAssessmentResultForLowerLimitNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm, calculator.DetailedAssessmentResultForFactorizedLowerLimitNormInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.DetailedAssessmentAssemblyGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(failureMechanismSection) + { + TailorMadeAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentGroupInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.TailorMadeAssemblyCategoryOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/Ringtoets.GrassCoverErosionOutwards.Data.Test.csproj =================================================================== diff -u -rf7d73da8b5830eb8d37f50e94eb85e22f3e6b1c3 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/Ringtoets.GrassCoverErosionOutwards.Data.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Data.Test.csproj) (revision f7d73da8b5830eb8d37f50e94eb85e22f3e6b1c3) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/Ringtoets.GrassCoverErosionOutwards.Data.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -21,7 +21,7 @@ - + Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,289 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.HeightStructures.Data +{ + /// + /// Factory for assembling assembly results for a height structures failure mechanism. + /// + public static class HeightStructuresFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleSimpleAssessment( + HeightStructuresFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleDetailedAssessment( + HeightStructuresFailureMechanismSectionResult failureMechanismSectionResult, + HeightStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult, + failureMechanismSectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleTailorMadeAssessment( + HeightStructuresFailureMechanismSectionResult failureMechanismSectionResult, + HeightStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult, + failureMechanismSectionResult.TailorMadeAssessmentProbability, + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleCombinedAssessment( + HeightStructuresFailureMechanismSectionResult failureMechanismSectionResult, + HeightStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanismSectionAssembly simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssembly detailedAssembly = AssembleDetailedAssessment( + failureMechanismSectionResult, failureMechanism, assessmentSection); + FailureMechanismSectionAssembly tailorMadeAssembly = AssembleTailorMadeAssessment( + failureMechanismSectionResult, failureMechanism, assessmentSection); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism to assemble for. + /// The the failure mechanism belongs to. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssembly AssembleFailureMechanism( + HeightStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + bool considerManualAssembly = true) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator sectionCalculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + AssemblyCategoriesInput assemblyCategoriesInput = CreateAssemblyCategoriesInput(failureMechanism, assessmentSection); + var sectionAssemblies = new List(); + + try + { + foreach (HeightStructuresFailureMechanismSectionResult sectionResult in failureMechanism.SectionResults) + { + if (sectionResult.UseManualAssemblyProbability && considerManualAssembly) + { + sectionAssemblies.Add(sectionCalculator.AssembleDetailedAssessment( + DetailedAssessmentProbabilityOnlyResultType.Probability, + sectionResult.ManualAssemblyProbability, + assemblyCategoriesInput)); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult, + failureMechanism, + assessmentSection)); + } + } + + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + return calculator.Assemble(sectionAssemblies, assemblyCategoriesInput); + } + catch (Exception e) when (e is FailureMechanismAssemblyCalculatorException || e is FailureMechanismSectionAssemblyCalculatorException) + { + throw new AssemblyException(e.Message, e); + } + } + + private static AssemblyCategoriesInput CreateAssemblyCategoriesInput(HeightStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + return new AssemblyCategoriesInput(failureMechanism.GeneralInput.N, + failureMechanism.Contribution, + assessmentSection.FailureMechanismContribution.SignalingNorm, + assessmentSection.FailureMechanismContribution.LowerLimitNorm); + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/Ringtoets.HeightStructures.Data.csproj =================================================================== diff -u -r739752c5cc7ed800dacf74e12221c227183ddc6f -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/Ringtoets.HeightStructures.Data.csproj (.../Ringtoets.HeightStructures.Data.csproj) (revision 739752c5cc7ed800dacf74e12221c227183ddc6f) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/Ringtoets.HeightStructures.Data.csproj (.../Ringtoets.HeightStructures.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -16,7 +16,7 @@ - + Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.cs =================================================================== diff -u -r03f260e74af2da4f651a4abad32e5416999c814a -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.cs (.../HeightStructuresFailureMechanismResultView.cs) (revision 03f260e74af2da4f651a4abad32e5416999c814a) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.cs (.../HeightStructuresFailureMechanismResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -75,7 +75,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultWithProbabilityControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(HeightStructuresFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); // The concat is needed to observe the input of calculations in child groups. calculationInputObserver = new RecursiveObserver( Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -r4994cf24768a7b54149e65713433dc4543ace82c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismSectionResultRow.cs (.../HeightStructuresFailureMechanismSectionResultRow.cs) (revision 4994cf24768a7b54149e65713433dc4543ace82c) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismSectionResultRow.cs (.../HeightStructuresFailureMechanismSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -361,7 +361,7 @@ { try { - simpleAssemblyCategoryGroup = HeightStructuresFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; + simpleAssemblyCategoryGroup = HeightStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; } catch (AssemblyException e) { @@ -374,7 +374,7 @@ { try { - detailedAssemblyCategoryGroup = HeightStructuresFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment( + detailedAssemblyCategoryGroup = HeightStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -390,7 +390,7 @@ { try { - tailorMadeAssemblyCategoryGroup = HeightStructuresFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment( + tailorMadeAssemblyCategoryGroup = HeightStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -407,7 +407,7 @@ try { FailureMechanismSectionAssembly combinedAssembly = - HeightStructuresFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + HeightStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult, failureMechanism, assessmentSection); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,837 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.Data.TestUtil; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.HeightStructures.Data.Test +{ + [TestFixture] + public class HeightStructuresFailureMechanismAssemblyFactoryTest + { + private static void AssertAssemblyCategoriesInput(IAssessmentSection assessmentSection, + HeightStructuresFailureMechanism failureMechanism, + AssemblyCategoriesInput assemblyCategoriesInput) + { + Assert.AreEqual(assessmentSection.FailureMechanismContribution.SignalingNorm, assemblyCategoriesInput.SignalingNorm); + Assert.AreEqual(assessmentSection.FailureMechanismContribution.LowerLimitNorm, assemblyCategoriesInput.LowerLimitNorm); + Assert.AreEqual(failureMechanism.Contribution, assemblyCategoriesInput.FailureMechanismContribution); + Assert.AreEqual(failureMechanism.GeneralInput.N, assemblyCategoriesInput.N); + } + + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new HeightStructuresFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + HeightStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new HeightStructuresFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + HeightStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new HeightStructuresFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + null, + new HeightStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new HeightStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + DetailedAssessmentResult = new Random(21).NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + HeightStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), + calculator.DetailedAssessmentProbabilityInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentProbabilityOnlyResultInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + HeightStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + null, + new HeightStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new HeightStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + HeightStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentProbability, calculator.TailorMadeAssessmentProbabilityInput); + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentProbabilityCalculationResultInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + HeightStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.TailorMadeAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null, + new HeightStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new HeightStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + HeightStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedSimpleAssembly = HeightStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssembly expectedDetailedAssembly = HeightStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + FailureMechanismSectionAssembly expectedTailorMadeAssembly = HeightStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + AssemblyToolTestHelper.AssertAreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + HeightStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.CombinedAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + new HeightStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = HeightStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + HeightStructuresFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = HeightStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + HeightStructuresFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection, + false); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = HeightStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssembly actualOutput = + HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + Assert.AreSame(calculator.FailureMechanismAssemblyOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/Ringtoets.HeightStructures.Data.Test.csproj =================================================================== diff -u -r00168da71b7ca2b94166ca16179535ed6d2131b4 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/Ringtoets.HeightStructures.Data.Test.csproj (.../Ringtoets.HeightStructures.Data.Test.csproj) (revision 00168da71b7ca2b94166ca16179535ed6d2131b4) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/Ringtoets.HeightStructures.Data.Test.csproj (.../Ringtoets.HeightStructures.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -21,7 +21,7 @@ - + Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -14,14 +14,14 @@ - - - - - - - - + + + + + + + + Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,219 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.StandAlone.AssemblyFactories +{ + /// + /// Factory for creating assembly results for a grass cover slip off inwards failure mechanism. + /// + public static class GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + GrassCoverSlipOffInwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment( + GrassCoverSlipOffInwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + GrassCoverSlipOffInwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + GrassCoverSlipOffInwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (GrassCoverSlipOffInwardsFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/GrassCoverSlipOffInwardsFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,219 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.StandAlone.AssemblyFactories +{ + /// + /// Factory for creating assembly results for a grass cover slip off outwards failure mechanism. + /// + public static class GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + GrassCoverSlipOffOutwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment( + GrassCoverSlipOffOutwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + GrassCoverSlipOffOutwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + GrassCoverSlipOffOutwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (GrassCoverSlipOffOutwardsFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/GrassCoverSlipOffOutwardsFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/MacroStabilityOutwardsFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/MacroStabilityOutwardsFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/MacroStabilityOutwardsFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,282 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.Probability; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.StandAlone.AssemblyFactories +{ + /// + /// Factory for creating assembly results for a macro stability outwards failure mechanism. + /// + public static class MacroStabilityOutwardsFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + MacroStabilityOutwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment( + MacroStabilityOutwardsFailureMechanismSectionResult failureMechanismSectionResult, + MacroStabilityOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult, + failureMechanismSectionResult.DetailedAssessmentProbability, + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + MacroStabilityOutwardsFailureMechanismSectionResult failureMechanismSectionResult, + MacroStabilityOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult, + failureMechanismSectionResult.TailorMadeAssessmentProbability, + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + MacroStabilityOutwardsFailureMechanismSectionResult failureMechanismSectionResult, + MacroStabilityOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = AssembleDetailedAssessment( + failureMechanismSectionResult, failureMechanism, assessmentSection); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment( + failureMechanismSectionResult, failureMechanism, assessmentSection); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism to assemble for. + /// The the failure mechanism belongs to. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + MacroStabilityOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + bool considerManualAssembly = true) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + var sectionAssemblies = new List(); + foreach (MacroStabilityOutwardsFailureMechanismSectionResult sectionResult in failureMechanism.SectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult, + failureMechanism, + assessmentSection)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + private static AssemblyCategoriesInput CreateAssemblyCategoriesInput(MacroStabilityOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + return new AssemblyCategoriesInput(failureMechanism.MacroStabilityOutwardsProbabilityAssessmentInput.GetN( + failureMechanism.MacroStabilityOutwardsProbabilityAssessmentInput.SectionLength), + failureMechanism.Contribution, + assessmentSection.FailureMechanismContribution.SignalingNorm, + assessmentSection.FailureMechanismContribution.LowerLimitNorm); + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/MicrostabilityFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/MicrostabilityFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/MicrostabilityFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,219 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.StandAlone.AssemblyFactories +{ + /// + /// Factory for creating assembly results for a microstability failure mechanism. + /// + public static class MicrostabilityFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + MicrostabilityFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment( + MicrostabilityFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + MicrostabilityFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + MicrostabilityFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (MicrostabilityFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/MicrostabilityFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/PipingStructureFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/PipingStructureFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/PipingStructureFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,219 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.StandAlone.AssemblyFactories +{ + /// + /// Factory for creating assembly results for a piping structure failure mechanism. + /// + public static class PipingStructureFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + PipingStructureFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment( + PipingStructureFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + PipingStructureFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + PipingStructureFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (PipingStructureFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/PipingStructureFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,185 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.StandAlone.AssemblyFactories +{ + /// + /// Factory for creating assembly results for a strength stability lengthwise construction failure mechanism. + /// + public static class StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, FailureMechanismSectionAssemblyCategoryGroup.None, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/TechnicalInnovationFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/TechnicalInnovationFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/TechnicalInnovationFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,185 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.StandAlone.AssemblyFactories +{ + /// + /// Factory for creating assembly results for a technical innovation failure mechanism. + /// + public static class TechnicalInnovationFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + TechnicalInnovationFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + TechnicalInnovationFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + TechnicalInnovationFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, FailureMechanismSectionAssemblyCategoryGroup.None, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (TechnicalInnovationFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/TechnicalInnovationFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,185 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.StandAlone.AssemblyFactories +{ + /// + /// Factory for creating assembly results for a water pressure asphalt cover failure mechanism. + /// + public static class WaterPressureAsphaltCoverFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + WaterPressureAsphaltCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + WaterPressureAsphaltCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + WaterPressureAsphaltCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, FailureMechanismSectionAssemblyCategoryGroup.None, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (WaterPressureAsphaltCoverFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/WaterPressureAsphaltCoverFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultTotalView.cs =================================================================== diff -u -raa964c373f22074011daf5673e15963f6d1d31e9 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultTotalView.cs (.../AssemblyResultTotalView.cs) (revision aa964c373f22074011daf5673e15963f6d1d31e9) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultTotalView.cs (.../AssemblyResultTotalView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -167,31 +167,31 @@ { ClosingStructuresFailureMechanism closingStructures = AssessmentSection.ClosingStructures; return new FailureMechanismAssemblyResultRow(closingStructures, - () => ClosingStructuresFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(closingStructures, + () => ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(closingStructures, AssessmentSection)); } private FailureMechanismAssemblyResultRow CreateHeightStructuresFailureMechanismAssemblyResultRow() { HeightStructuresFailureMechanism heightStructures = AssessmentSection.HeightStructures; return new FailureMechanismAssemblyResultRow(heightStructures, - () => HeightStructuresFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(heightStructures, + () => HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(heightStructures, AssessmentSection)); } private FailureMechanismAssemblyResultRow CreateStabilityPointsStructuresFailureMechanismAssemblyResultRow() { StabilityPointStructuresFailureMechanism stabilityPointStructures = AssessmentSection.StabilityPointStructures; return new FailureMechanismAssemblyResultRow(stabilityPointStructures, - () => StabilityPointStructuresFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(stabilityPointStructures, + () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(stabilityPointStructures, AssessmentSection)); } private FailureMechanismAssemblyResultRow CreateGrassCoverErosionInwardsFailureMechanismAssemblyResultRow() { GrassCoverErosionInwardsFailureMechanism grassCoverErosionInwards = AssessmentSection.GrassCoverErosionInwards; return new FailureMechanismAssemblyResultRow(grassCoverErosionInwards, - () => GrassCoverErosionInwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(grassCoverErosionInwards, + () => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(grassCoverErosionInwards, AssessmentSection)); } @@ -203,15 +203,15 @@ { PipingFailureMechanism piping = AssessmentSection.Piping; return new FailureMechanismAssemblyResultRow(piping, - () => PipingFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(piping, + () => PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism(piping, AssessmentSection)); } private FailureMechanismAssemblyResultRowBase CreateMacroStabilityInwardsFailureMechanismAssemblyResultRow() { MacroStabilityInwardsFailureMechanism macroStabilityInwards = AssessmentSection.MacroStabilityInwards; return new FailureMechanismAssemblyResultRow(macroStabilityInwards, - () => MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(macroStabilityInwards, + () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(macroStabilityInwards, AssessmentSection)); } @@ -223,28 +223,28 @@ { StabilityStoneCoverFailureMechanism stabilityStoneCover = AssessmentSection.StabilityStoneCover; return new FailureMechanismAssemblyCategoryGroupResultRow(stabilityStoneCover, - () => StabilityStoneCoverFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(stabilityStoneCover.SectionResults)); + () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(stabilityStoneCover.SectionResults)); } private FailureMechanismAssemblyCategoryGroupResultRow CreateWaveImpactFailureMechanismAssemblyResultRow() { WaveImpactAsphaltCoverFailureMechanism waveImpactAsphaltCover = AssessmentSection.WaveImpactAsphaltCover; return new FailureMechanismAssemblyCategoryGroupResultRow(waveImpactAsphaltCover, - () => WaveImpactAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(waveImpactAsphaltCover.SectionResults)); + () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(waveImpactAsphaltCover.SectionResults)); } private FailureMechanismAssemblyCategoryGroupResultRow CreateGrassCoverErosionOutwardsFailureMechanismAssemblyResultRow() { GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwards = AssessmentSection.GrassCoverErosionOutwards; return new FailureMechanismAssemblyCategoryGroupResultRow(grassCoverErosionOutwards, - () => GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(grassCoverErosionOutwards.SectionResults)); + () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(grassCoverErosionOutwards.SectionResults)); } private FailureMechanismAssemblyCategoryGroupResultRow CreateDuneErosionFailureMechanismAssemblyResultRow() { DuneErosionFailureMechanism duneErosion = AssessmentSection.DuneErosion; return new FailureMechanismAssemblyCategoryGroupResultRow(duneErosion, - () => DuneErosionFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(duneErosion.SectionResults)); + () => DuneErosionFailureMechanismAssemblyFactory.AssembleFailureMechanism(duneErosion.SectionResults)); } #endregion @@ -255,57 +255,57 @@ { MacroStabilityOutwardsFailureMechanism macroStabilityOutwards = AssessmentSection.MacroStabilityOutwards; return new FailureMechanismAssemblyCategoryGroupResultRow(macroStabilityOutwards, - () => MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(macroStabilityOutwards, + () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(macroStabilityOutwards, AssessmentSection)); } private FailureMechanismAssemblyCategoryGroupResultRow CreateMicrostabilityFailureMechanismAssemblyResultRow() { MicrostabilityFailureMechanism microstability = AssessmentSection.Microstability; return new FailureMechanismAssemblyCategoryGroupResultRow(microstability, - () => MicrostabilityFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(microstability.SectionResults)); + () => MicrostabilityFailureMechanismAssemblyFactory.AssembleFailureMechanism(microstability.SectionResults)); } private FailureMechanismAssemblyCategoryGroupResultRow CreateWaterPressureAsphaltCoverFailureMechanismAssemblyResultRow() { WaterPressureAsphaltCoverFailureMechanism waterPressureAsphaltCover = AssessmentSection.WaterPressureAsphaltCover; return new FailureMechanismAssemblyCategoryGroupResultRow(waterPressureAsphaltCover, - () => WaterPressureAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(waterPressureAsphaltCover.SectionResults)); + () => WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(waterPressureAsphaltCover.SectionResults)); } private FailureMechanismAssemblyCategoryGroupResultRow CreateGrassCoverSlipOffOutwardsFailureMechanismAssemblyResultRow() { GrassCoverSlipOffOutwardsFailureMechanism grassCoverSlipOffOutwards = AssessmentSection.GrassCoverSlipOffOutwards; return new FailureMechanismAssemblyCategoryGroupResultRow(grassCoverSlipOffOutwards, - () => GrassCoverSlipOffOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(grassCoverSlipOffOutwards.SectionResults)); + () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(grassCoverSlipOffOutwards.SectionResults)); } private FailureMechanismAssemblyCategoryGroupResultRow CreateGrassCoverSlipOffInwardsFailureMechanismAssemblyResultRow() { GrassCoverSlipOffInwardsFailureMechanism grassCoverSlipOffInwards = AssessmentSection.GrassCoverSlipOffInwards; return new FailureMechanismAssemblyCategoryGroupResultRow(grassCoverSlipOffInwards, - () => GrassCoverSlipOffInwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(grassCoverSlipOffInwards.SectionResults)); + () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(grassCoverSlipOffInwards.SectionResults)); } private FailureMechanismAssemblyCategoryGroupResultRow CreatePipingStructureFailureMechanismAssemblyResultRow() { PipingStructureFailureMechanism pipingStructure = AssessmentSection.PipingStructure; return new FailureMechanismAssemblyCategoryGroupResultRow(pipingStructure, - () => PipingStructureFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(pipingStructure.SectionResults)); + () => PipingStructureFailureMechanismAssemblyFactory.AssembleFailureMechanism(pipingStructure.SectionResults)); } private FailureMechanismAssemblyCategoryGroupResultRow CreateStrengthStabilityLengthWiseConstructionFailureMechanismAssemblyResultRow() { StrengthStabilityLengthwiseConstructionFailureMechanism strengthStabilityLengthwiseConstruction = AssessmentSection.StrengthStabilityLengthwiseConstruction; return new FailureMechanismAssemblyCategoryGroupResultRow(strengthStabilityLengthwiseConstruction, - () => StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(strengthStabilityLengthwiseConstruction.SectionResults)); + () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleFailureMechanism(strengthStabilityLengthwiseConstruction.SectionResults)); } private FailureMechanismAssemblyCategoryGroupResultRow CreateTechnicalInnovationFailureMechanismAssemblyResultRow() { TechnicalInnovationFailureMechanism technicalInnovation = AssessmentSection.TechnicalInnovation; return new FailureMechanismAssemblyCategoryGroupResultRow(technicalInnovation, - () => TechnicalInnovationFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(technicalInnovation.SectionResults)); + () => TechnicalInnovationFailureMechanismAssemblyFactory.AssembleFailureMechanism(technicalInnovation.SectionResults)); } #endregion Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/GrassCoverSlipOffInwardsSectionResultRow.cs =================================================================== diff -u -r4994cf24768a7b54149e65713433dc4543ace82c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/GrassCoverSlipOffInwardsSectionResultRow.cs (.../GrassCoverSlipOffInwardsSectionResultRow.cs) (revision 4994cf24768a7b54149e65713433dc4543ace82c) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/GrassCoverSlipOffInwardsSectionResultRow.cs (.../GrassCoverSlipOffInwardsSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -269,7 +269,7 @@ { try { - simpleAssemblyCategoryGroup = GrassCoverSlipOffInwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -282,7 +282,7 @@ { try { - detailedAssemblyCategoryGroup = GrassCoverSlipOffInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment(SectionResult); + detailedAssemblyCategoryGroup = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(SectionResult); } catch (AssemblyException e) { @@ -295,7 +295,7 @@ { try { - tailorMadeAssemblyCategoryGroup = GrassCoverSlipOffInwardsFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -308,7 +308,7 @@ { try { - combinedAssemblyCategoryGroup = GrassCoverSlipOffInwardsFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment(SectionResult); + combinedAssemblyCategoryGroup = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(SectionResult); } catch (AssemblyException e) { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/GrassCoverSlipOffOutwardsSectionResultRow.cs =================================================================== diff -u -r845bc0316bfb8173d53a1d002686fc9a6a631ee1 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/GrassCoverSlipOffOutwardsSectionResultRow.cs (.../GrassCoverSlipOffOutwardsSectionResultRow.cs) (revision 845bc0316bfb8173d53a1d002686fc9a6a631ee1) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/GrassCoverSlipOffOutwardsSectionResultRow.cs (.../GrassCoverSlipOffOutwardsSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -269,7 +269,7 @@ { try { - simpleAssemblyCategoryGroup = GrassCoverSlipOffOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -282,7 +282,7 @@ { try { - detailedAssemblyCategoryGroup = GrassCoverSlipOffOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment(SectionResult); + detailedAssemblyCategoryGroup = GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(SectionResult); } catch (AssemblyException e) { @@ -295,7 +295,7 @@ { try { - tailorMadeAssemblyCategoryGroup = GrassCoverSlipOffOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -308,7 +308,7 @@ { try { - combinedAssemblyCategoryGroup = GrassCoverSlipOffOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment(SectionResult); + combinedAssemblyCategoryGroup = GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(SectionResult); } catch (AssemblyException e) { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs =================================================================== diff -u -r4994cf24768a7b54149e65713433dc4543ace82c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision 4994cf24768a7b54149e65713433dc4543ace82c) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -340,7 +340,7 @@ { try { - simpleAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -353,7 +353,7 @@ { try { - detailedAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment( + detailedAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( SectionResult, failureMechanism, assessmentSection); @@ -369,7 +369,7 @@ { try { - tailorMadeAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment( + tailorMadeAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( SectionResult, failureMechanism, assessmentSection); @@ -385,7 +385,7 @@ { try { - combinedAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + combinedAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult, failureMechanism, assessmentSection); Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MicrostabilitySectionResultRow.cs =================================================================== diff -u -r4994cf24768a7b54149e65713433dc4543ace82c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MicrostabilitySectionResultRow.cs (.../MicrostabilitySectionResultRow.cs) (revision 4994cf24768a7b54149e65713433dc4543ace82c) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MicrostabilitySectionResultRow.cs (.../MicrostabilitySectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -270,7 +270,7 @@ { try { - simpleAssemblyCategoryGroup = MicrostabilityFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = MicrostabilityFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -283,7 +283,7 @@ { try { - detailedAssemblyCategoryGroup = MicrostabilityFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment(SectionResult); + detailedAssemblyCategoryGroup = MicrostabilityFailureMechanismAssemblyFactory.AssembleDetailedAssessment(SectionResult); } catch (AssemblyException e) { @@ -296,7 +296,7 @@ { try { - tailorMadeAssemblyCategoryGroup = MicrostabilityFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = MicrostabilityFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -309,7 +309,7 @@ { try { - combinedAssemblyCategoryGroup = MicrostabilityFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment(SectionResult); + combinedAssemblyCategoryGroup = MicrostabilityFailureMechanismAssemblyFactory.AssembleCombinedAssessment(SectionResult); } catch (AssemblyException e) { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/PipingStructureSectionResultRow.cs =================================================================== diff -u -r4994cf24768a7b54149e65713433dc4543ace82c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/PipingStructureSectionResultRow.cs (.../PipingStructureSectionResultRow.cs) (revision 4994cf24768a7b54149e65713433dc4543ace82c) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/PipingStructureSectionResultRow.cs (.../PipingStructureSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -269,7 +269,7 @@ { try { - simpleAssemblyCategoryGroup = PipingStructureFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = PipingStructureFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -282,7 +282,7 @@ { try { - detailedAssemblyCategoryGroup = PipingStructureFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment(SectionResult); + detailedAssemblyCategoryGroup = PipingStructureFailureMechanismAssemblyFactory.AssembleDetailedAssessment(SectionResult); } catch (AssemblyException e) { @@ -295,7 +295,7 @@ { try { - tailorMadeAssemblyCategoryGroup = PipingStructureFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = PipingStructureFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -308,7 +308,7 @@ { try { - combinedAssemblyCategoryGroup = PipingStructureFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment(SectionResult); + combinedAssemblyCategoryGroup = PipingStructureFailureMechanismAssemblyFactory.AssembleCombinedAssessment(SectionResult); } catch (AssemblyException e) { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/StrengthStabilityLengthwiseConstructionSectionResultRow.cs =================================================================== diff -u -r4994cf24768a7b54149e65713433dc4543ace82c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/StrengthStabilityLengthwiseConstructionSectionResultRow.cs (.../StrengthStabilityLengthwiseConstructionSectionResultRow.cs) (revision 4994cf24768a7b54149e65713433dc4543ace82c) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/StrengthStabilityLengthwiseConstructionSectionResultRow.cs (.../StrengthStabilityLengthwiseConstructionSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -229,7 +229,7 @@ { try { - simpleAssemblyCategoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -242,7 +242,7 @@ { try { - tailorMadeAssemblyCategoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -255,7 +255,7 @@ { try { - combinedAssemblyCategoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment(SectionResult); + combinedAssemblyCategoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(SectionResult); } catch (AssemblyException e) { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/TechnicalInnovationSectionResultRow.cs =================================================================== diff -u -r845bc0316bfb8173d53a1d002686fc9a6a631ee1 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/TechnicalInnovationSectionResultRow.cs (.../TechnicalInnovationSectionResultRow.cs) (revision 845bc0316bfb8173d53a1d002686fc9a6a631ee1) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/TechnicalInnovationSectionResultRow.cs (.../TechnicalInnovationSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -228,7 +228,7 @@ { try { - simpleAssemblyCategoryGroup = TechnicalInnovationFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = TechnicalInnovationFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -241,7 +241,7 @@ { try { - tailorMadeAssemblyCategoryGroup = TechnicalInnovationFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = TechnicalInnovationFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -254,7 +254,7 @@ { try { - combinedAssemblyCategoryGroup = TechnicalInnovationFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment(SectionResult); + combinedAssemblyCategoryGroup = TechnicalInnovationFailureMechanismAssemblyFactory.AssembleCombinedAssessment(SectionResult); } catch (AssemblyException e) { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/WaterPressureAsphaltCoverSectionResultRow.cs =================================================================== diff -u -r845bc0316bfb8173d53a1d002686fc9a6a631ee1 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/WaterPressureAsphaltCoverSectionResultRow.cs (.../WaterPressureAsphaltCoverSectionResultRow.cs) (revision 845bc0316bfb8173d53a1d002686fc9a6a631ee1) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/WaterPressureAsphaltCoverSectionResultRow.cs (.../WaterPressureAsphaltCoverSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -228,7 +228,7 @@ { try { - simpleAssemblyCategoryGroup = WaterPressureAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -241,7 +241,7 @@ { try { - tailorMadeAssemblyCategoryGroup = WaterPressureAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -254,7 +254,7 @@ { try { - combinedAssemblyCategoryGroup = WaterPressureAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment(SectionResult); + combinedAssemblyCategoryGroup = WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(SectionResult); } catch (AssemblyException e) { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/GrassCoverSlipOffInwardsResultView.cs =================================================================== diff -u -r6bea7a2178b1eb8111477cd63f1086d679ec7e20 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/GrassCoverSlipOffInwardsResultView.cs (.../GrassCoverSlipOffInwardsResultView.cs) (revision 6bea7a2178b1eb8111477cd63f1086d679ec7e20) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/GrassCoverSlipOffInwardsResultView.cs (.../GrassCoverSlipOffInwardsResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -56,7 +56,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(GrassCoverSlipOffInwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override GrassCoverSlipOffInwardsSectionResultRow CreateFailureMechanismSectionResultRow( Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/GrassCoverSlipOffOutwardsResultView.cs =================================================================== diff -u -r6bea7a2178b1eb8111477cd63f1086d679ec7e20 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/GrassCoverSlipOffOutwardsResultView.cs (.../GrassCoverSlipOffOutwardsResultView.cs) (revision 6bea7a2178b1eb8111477cd63f1086d679ec7e20) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/GrassCoverSlipOffOutwardsResultView.cs (.../GrassCoverSlipOffOutwardsResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -57,7 +57,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(GrassCoverSlipOffOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override GrassCoverSlipOffOutwardsSectionResultRow CreateFailureMechanismSectionResultRow(GrassCoverSlipOffOutwardsFailureMechanismSectionResult sectionResult) Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacroStabilityOutwardsResultView.cs =================================================================== diff -u -r3ceb247a5a3b58e8ab0793bf6ff3f1395890a9f8 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacroStabilityOutwardsResultView.cs (.../MacroStabilityOutwardsResultView.cs) (revision 3ceb247a5a3b58e8ab0793bf6ff3f1395890a9f8) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacroStabilityOutwardsResultView.cs (.../MacroStabilityOutwardsResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -71,7 +71,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); } protected override MacroStabilityOutwardsSectionResultRow CreateFailureMechanismSectionResultRow(MacroStabilityOutwardsFailureMechanismSectionResult sectionResult) Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MicrostabilityResultView.cs =================================================================== diff -u -r6bea7a2178b1eb8111477cd63f1086d679ec7e20 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MicrostabilityResultView.cs (.../MicrostabilityResultView.cs) (revision 6bea7a2178b1eb8111477cd63f1086d679ec7e20) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MicrostabilityResultView.cs (.../MicrostabilityResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -56,7 +56,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(MicrostabilityFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(MicrostabilityFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override MicrostabilitySectionResultRow CreateFailureMechanismSectionResultRow(MicrostabilityFailureMechanismSectionResult sectionResult) Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/PipingStructureResultView.cs =================================================================== diff -u -r6bea7a2178b1eb8111477cd63f1086d679ec7e20 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/PipingStructureResultView.cs (.../PipingStructureResultView.cs) (revision 6bea7a2178b1eb8111477cd63f1086d679ec7e20) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/PipingStructureResultView.cs (.../PipingStructureResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -56,7 +56,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(PipingStructureFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(PipingStructureFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override PipingStructureSectionResultRow CreateFailureMechanismSectionResultRow(PipingStructureFailureMechanismSectionResult sectionResult) Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultView.cs =================================================================== diff -u -r6bea7a2178b1eb8111477cd63f1086d679ec7e20 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultView.cs (.../StrengthStabilityLengthwiseConstructionResultView.cs) (revision 6bea7a2178b1eb8111477cd63f1086d679ec7e20) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultView.cs (.../StrengthStabilityLengthwiseConstructionResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -57,7 +57,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override StrengthStabilityLengthwiseConstructionSectionResultRow CreateFailureMechanismSectionResultRow( Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/TechnicalInnovationResultView.cs =================================================================== diff -u -r6bea7a2178b1eb8111477cd63f1086d679ec7e20 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/TechnicalInnovationResultView.cs (.../TechnicalInnovationResultView.cs) (revision 6bea7a2178b1eb8111477cd63f1086d679ec7e20) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/TechnicalInnovationResultView.cs (.../TechnicalInnovationResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -55,7 +55,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(TechnicalInnovationFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(TechnicalInnovationFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override TechnicalInnovationSectionResultRow CreateFailureMechanismSectionResultRow(TechnicalInnovationFailureMechanismSectionResult sectionResult) Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/WaterPressureAsphaltCoverResultView.cs =================================================================== diff -u -r6bea7a2178b1eb8111477cd63f1086d679ec7e20 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/WaterPressureAsphaltCoverResultView.cs (.../WaterPressureAsphaltCoverResultView.cs) (revision 6bea7a2178b1eb8111477cd63f1086d679ec7e20) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/WaterPressureAsphaltCoverResultView.cs (.../WaterPressureAsphaltCoverResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -55,7 +55,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(WaterPressureAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override WaterPressureAsphaltCoverSectionResultRow CreateFailureMechanismSectionResultRow(WaterPressureAsphaltCoverFailureMechanismSectionResult sectionResult) Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -21,14 +21,14 @@ - - - - - - - - + + + + + + + + Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/GrassCoverSlipOffInwardsFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/GrassCoverSlipOffInwardsFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/GrassCoverSlipOffInwardsFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,505 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone.AssemblyFactories +{ + [TestFixture] + public class GrassCoverSlipOffInwardsFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreEqual(calculatorOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentResultInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.DetailedAssessmentAssemblyGroupOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentResultInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.TailorMadeAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new GrassCoverSlipOffInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/GrassCoverSlipOffInwardsFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,504 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone.AssemblyFactories +{ + [TestFixture] + public class GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentResultInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.DetailedAssessmentAssemblyGroupOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentResultInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.TailorMadeAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly = GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => GrassCoverSlipOffOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/GrassCoverSlipOffOutwardsFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/MacroStabilityOutwardsFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/MacroStabilityOutwardsFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/MacroStabilityOutwardsFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,805 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone.AssemblyFactories +{ + [TestFixture] + public class MacroStabilityOutwardsFailureMechanismAssemblyFactoryTest + { + private static void AssertAssemblyCategoriesInput(IAssessmentSection assessmentSection, + MacroStabilityOutwardsFailureMechanism failureMechanism, + AssemblyCategoriesInput assemblyCategoriesInput) + { + Assert.AreEqual(assessmentSection.FailureMechanismContribution.SignalingNorm, assemblyCategoriesInput.SignalingNorm); + Assert.AreEqual(assessmentSection.FailureMechanismContribution.LowerLimitNorm, assemblyCategoriesInput.LowerLimitNorm); + Assert.AreEqual(failureMechanism.Contribution, assemblyCategoriesInput.FailureMechanismContribution); + Assert.AreEqual(failureMechanism.MacroStabilityOutwardsProbabilityAssessmentInput.GetN( + failureMechanism.MacroStabilityOutwardsProbabilityAssessmentInput.SectionLength), assemblyCategoriesInput.N); + } + + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreEqual(calculatorOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + null, + new MacroStabilityOutwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new MacroStabilityOutwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentProbabilityOnlyResultInput); + Assert.AreEqual(sectionResult.DetailedAssessmentProbability, calculator.DetailedAssessmentProbabilityInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput; + Assert.AreEqual(calculatorOutput.Group, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + null, + new MacroStabilityOutwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new MacroStabilityOutwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentProbability, calculator.TailorMadeAssessmentProbabilityInput); + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentProbabilityAndDetailedCalculationResultInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.TailorMadeAssessmentAssemblyOutput; + Assert.AreEqual(calculatorOutput.Group, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null, + new MacroStabilityOutwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new MacroStabilityOutwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + new MacroStabilityOutwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + MacroStabilityOutwardsFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyCategoryGroup = true; + sectionResult.ManualAssemblyCategoryGroup = new Random(39).NextEnumValue(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(failureMechanism.SectionResults.Single().ManualAssemblyCategoryGroup, + calculator.FailureMechanismSectionCategories.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + MacroStabilityOutwardsFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyCategoryGroup = true; + sectionResult.ManualAssemblyCategoryGroup = new Random(39).NextEnumValue(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection, + false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/MicrostabilityFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/MicrostabilityFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/MicrostabilityFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,505 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone.AssemblyFactories +{ + [TestFixture] + public class MicrostabilityFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new MicrostabilityFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MicrostabilityFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new MicrostabilityFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + MicrostabilityFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreEqual(calculatorOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new MicrostabilityFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleDetailedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MicrostabilityFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentResultInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + MicrostabilityFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.DetailedAssessmentAssemblyGroupOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MicrostabilityFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentResultInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + MicrostabilityFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.TailorMadeAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleCombinedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MicrostabilityFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = MicrostabilityFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly = MicrostabilityFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = MicrostabilityFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + MicrostabilityFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + MicrostabilityFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + MicrostabilityFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + MicrostabilityFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new MicrostabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + MicrostabilityFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + MicrostabilityFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + MicrostabilityFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MicrostabilityFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/MicrostabilityFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/PipingStructureFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/PipingStructureFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/PipingStructureFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,505 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone.AssemblyFactories +{ + [TestFixture] + public class PipingStructureFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new PipingStructureFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + PipingStructureFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new PipingStructureFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + PipingStructureFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreEqual(calculatorOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new PipingStructureFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleDetailedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + PipingStructureFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentResultInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + PipingStructureFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.DetailedAssessmentAssemblyGroupOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + PipingStructureFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentResultInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + PipingStructureFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.TailorMadeAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleCombinedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + PipingStructureFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = PipingStructureFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly = PipingStructureFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = PipingStructureFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + PipingStructureFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + PipingStructureFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + PipingStructureFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + PipingStructureFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new PipingStructureFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + PipingStructureFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + PipingStructureFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + PipingStructureFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => PipingStructureFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/PipingStructureFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,425 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone.AssemblyFactories +{ + [TestFixture] + public class StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreEqual(calculatorOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentResultInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.TailorMadeAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(FailureMechanismSectionAssemblyCategoryGroup.None, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/TechnicalInnovationFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/TechnicalInnovationFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/TechnicalInnovationFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,424 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone.AssemblyFactories +{ + [TestFixture] + public class TechnicalInnovationFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => TechnicalInnovationFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new TechnicalInnovationFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new TechnicalInnovationFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new TechnicalInnovationFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => TechnicalInnovationFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => TechnicalInnovationFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new TechnicalInnovationFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentResultInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new TechnicalInnovationFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.TailorMadeAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new TechnicalInnovationFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => TechnicalInnovationFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => TechnicalInnovationFailureMechanismAssemblyFactory.AssembleCombinedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new TechnicalInnovationFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = TechnicalInnovationFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = TechnicalInnovationFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(FailureMechanismSectionAssemblyCategoryGroup.None, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new TechnicalInnovationFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new TechnicalInnovationFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => TechnicalInnovationFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => TechnicalInnovationFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new TechnicalInnovationFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new TechnicalInnovationFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new TechnicalInnovationFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + TechnicalInnovationFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => TechnicalInnovationFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/TechnicalInnovationFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/WaterPressureAsphaltCoverFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/WaterPressureAsphaltCoverFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/WaterPressureAsphaltCoverFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,424 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Data.Test.StandAlone.AssemblyFactories +{ + [TestFixture] + public class WaterPressureAsphaltCoverFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaterPressureAsphaltCoverFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaterPressureAsphaltCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaterPressureAsphaltCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new WaterPressureAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentResultInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new WaterPressureAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.TailorMadeAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new WaterPressureAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new WaterPressureAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(FailureMechanismSectionAssemblyCategoryGroup.None, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new WaterPressureAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new WaterPressureAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new WaterPressureAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new WaterPressureAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new WaterPressureAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/WaterPressureAsphaltCoverFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,310 @@ +// 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 System.Collections.Generic; +using System.Linq; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.Probability; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.MacroStabilityInwards.Data +{ + /// + /// Factory for assembling assembly results for a macro stability inwards failure mechanism. + /// + public static class MacroStabilityInwardsFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleSimpleAssessment( + MacroStabilityInwardsFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// The calculation scenarios belonging to this section. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleDetailedAssessment( + MacroStabilityInwardsFailureMechanismSectionResult failureMechanismSectionResult, + IEnumerable calculationScenarios, + MacroStabilityInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (calculationScenarios == null) + { + throw new ArgumentNullException(nameof(calculationScenarios)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult, + failureMechanismSectionResult.GetDetailedAssessmentProbability(calculationScenarios, failureMechanism, assessmentSection), + failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(failureMechanismSectionResult.Section.Length), + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleTailorMadeAssessment( + MacroStabilityInwardsFailureMechanismSectionResult failureMechanismSectionResult, + MacroStabilityInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult, + failureMechanismSectionResult.TailorMadeAssessmentProbability, + failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(failureMechanismSectionResult.Section.Length), + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// The calculation scenarios belonging to this section. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleCombinedAssessment( + MacroStabilityInwardsFailureMechanismSectionResult failureMechanismSectionResult, + IEnumerable calculationScenarios, + MacroStabilityInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (calculationScenarios == null) + { + throw new ArgumentNullException(nameof(calculationScenarios)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanismSectionAssembly simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssembly detailedAssembly = AssembleDetailedAssessment( + failureMechanismSectionResult, calculationScenarios, failureMechanism, assessmentSection); + FailureMechanismSectionAssembly tailorMadeAssembly = AssembleTailorMadeAssessment( + failureMechanismSectionResult, failureMechanism, assessmentSection); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism to assemble for. + /// The the failure mechanism belongs to. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssembly AssembleFailureMechanism( + MacroStabilityInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + bool considerManualAssembly = true) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator sectionCalculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + AssemblyCategoriesInput assemblyCategoriesInput = CreateAssemblyCategoriesInput(failureMechanism, assessmentSection); + var sectionAssemblies = new List(); + + try + { + foreach (MacroStabilityInwardsFailureMechanismSectionResult sectionResult in failureMechanism.SectionResults) + { + if (sectionResult.UseManualAssemblyProbability && considerManualAssembly) + { + sectionAssemblies.Add(sectionCalculator.AssembleDetailedAssessment( + DetailedAssessmentProbabilityOnlyResultType.Probability, + sectionResult.ManualAssemblyProbability, + failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(sectionResult.Section.Length), + assemblyCategoriesInput)); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult, + failureMechanism.Calculations.Cast(), + failureMechanism, + assessmentSection)); + } + } + + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + return calculator.Assemble(sectionAssemblies, assemblyCategoriesInput); + } + catch (Exception e) when (e is FailureMechanismAssemblyCalculatorException || e is FailureMechanismSectionAssemblyCalculatorException) + { + throw new AssemblyException(e.Message, e); + } + } + + private static AssemblyCategoriesInput CreateAssemblyCategoriesInput(MacroStabilityInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + return new AssemblyCategoriesInput(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN( + failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.SectionLength), + failureMechanism.Contribution, + assessmentSection.FailureMechanismContribution.SignalingNorm, + assessmentSection.FailureMechanismContribution.LowerLimitNorm); + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj =================================================================== diff -u -r739752c5cc7ed800dacf74e12221c227183ddc6f -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision 739752c5cc7ed800dacf74e12221c227183ddc6f) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -14,7 +14,7 @@ - + Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismResultView.cs =================================================================== diff -u -r03f260e74af2da4f651a4abad32e5416999c814a -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismResultView.cs (.../MacroStabilityInwardsFailureMechanismResultView.cs) (revision 03f260e74af2da4f651a4abad32e5416999c814a) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismResultView.cs (.../MacroStabilityInwardsFailureMechanismResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -73,7 +73,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultWithProbabilityControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); // The concat is needed to observe the input of calculations in child groups. calculationInputObserver = new RecursiveObserver( Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs =================================================================== diff -u -r4994cf24768a7b54149e65713433dc4543ace82c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRow.cs) (revision 4994cf24768a7b54149e65713433dc4543ace82c) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -403,7 +403,7 @@ { try { - simpleAssemblyCategoryGroup = MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; + simpleAssemblyCategoryGroup = MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; } catch (AssemblyException e) { @@ -416,7 +416,7 @@ { try { - detailedAssemblyCategoryGroup = MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment( + detailedAssemblyCategoryGroup = MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( SectionResult, calculations, failureMechanism, @@ -433,7 +433,7 @@ { try { - tailorMadeAssemblyCategoryGroup = MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment( + tailorMadeAssemblyCategoryGroup = MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -450,7 +450,7 @@ try { FailureMechanismSectionAssembly combinedAssembly = - MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult, calculations, failureMechanism, Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,919 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.Data.TestUtil; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.MacroStabilityInwards.Data.TestUtil; + +namespace Ringtoets.MacroStabilityInwards.Data.Test +{ + [TestFixture] + public class MacroStabilityInwardsFailureMechanismAssemblyFactoryTest + { + private static void AssertAssemblyCategoriesInput(IAssessmentSection assessmentSection, + MacroStabilityInwardsFailureMechanism failureMechanism, + AssemblyCategoriesInput assemblyCategoriesInput) + { + Assert.AreEqual(assessmentSection.FailureMechanismContribution.SignalingNorm, assemblyCategoriesInput.SignalingNorm); + Assert.AreEqual(assessmentSection.FailureMechanismContribution.LowerLimitNorm, assemblyCategoriesInput.LowerLimitNorm); + Assert.AreEqual(failureMechanism.Contribution, assemblyCategoriesInput.FailureMechanismContribution); + Assert.AreEqual(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN( + failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.SectionLength), + assemblyCategoriesInput.N); + } + + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + null, + Enumerable.Empty(), + new MacroStabilityInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_CalculationScenariosNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + new MacroStabilityInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("calculationScenarios", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + Enumerable.Empty(), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + Enumerable.Empty(), + new MacroStabilityInwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + var assessmentSection = new AssessmentSectionStub(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }, true); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + MacroStabilityInwardsCalculationScenario[] calculationScenarios = + { + MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(hydraulicBoundaryLocation) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + calculationScenarios, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentProbabilityOnlyResultInput); + Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability( + calculationScenarios, + failureMechanism, + assessmentSection), + calculator.DetailedAssessmentProbabilityInput); + Assert.AreEqual(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(sectionResult.Section.Length), + calculator.DetailedAssessmentNInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + var assessmentSection = new AssessmentSectionStub(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }, true); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + new[] + { + MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(hydraulicBoundaryLocation) + }, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + var assessmentSection = new AssessmentSectionStub(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }, true); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + new[] + { + MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(hydraulicBoundaryLocation) + }, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + null, + new MacroStabilityInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new MacroStabilityInwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentProbability, calculator.TailorMadeAssessmentProbabilityInput); + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentProbabilityCalculationResultInput); + Assert.AreEqual(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(sectionResult.Section.Length), + calculator.TailorMadeAssessmentNInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.TailorMadeAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null, + Enumerable.Empty(), + new MacroStabilityInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_CalculationScenariosNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + new MacroStabilityInwardsFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("calculationScenarios", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + Enumerable.Empty(), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + Enumerable.Empty(), + new MacroStabilityInwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedSimpleAssembly = MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssembly expectedDetailedAssembly = MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + Enumerable.Empty(), + failureMechanism, + assessmentSection); + FailureMechanismSectionAssembly expectedTailorMadeAssembly = MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + AssemblyToolTestHelper.AssertAreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.CombinedAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + new MacroStabilityInwardsFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + MacroStabilityInwardsFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + failureMechanism.SectionResults.Single(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + MacroStabilityInwardsFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection, + false); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssembly actualOutput = + MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + Assert.AreSame(calculator.FailureMechanismAssemblyOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj =================================================================== diff -u -rd4cce2ae108af5d3fd689019d57793a440166f82 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision d4cce2ae108af5d3fd689019d57793a440166f82) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -23,7 +23,7 @@ - + Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,310 @@ +// 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 System.Collections.Generic; +using System.Linq; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.Probability; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.Piping.Data +{ + /// + /// Factory for assembling assembly results for a piping failure mechanism. + /// + public static class PipingFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleSimpleAssessment( + PipingFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// The calculation scenarios belonging to this section. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleDetailedAssessment( + PipingFailureMechanismSectionResult failureMechanismSectionResult, + IEnumerable calculationScenarios, + PipingFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (calculationScenarios == null) + { + throw new ArgumentNullException(nameof(calculationScenarios)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult, + failureMechanismSectionResult.GetDetailedAssessmentProbability(calculationScenarios, failureMechanism, assessmentSection), + failureMechanism.PipingProbabilityAssessmentInput.GetN(failureMechanismSectionResult.Section.Length), + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleTailorMadeAssessment( + PipingFailureMechanismSectionResult failureMechanismSectionResult, + PipingFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult, + failureMechanismSectionResult.TailorMadeAssessmentProbability, + failureMechanism.PipingProbabilityAssessmentInput.GetN(failureMechanismSectionResult.Section.Length), + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// The calculation scenarios belonging to this section. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleCombinedAssessment( + PipingFailureMechanismSectionResult failureMechanismSectionResult, + IEnumerable calculationScenarios, + PipingFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (calculationScenarios == null) + { + throw new ArgumentNullException(nameof(calculationScenarios)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanismSectionAssembly simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssembly detailedAssembly = AssembleDetailedAssessment( + failureMechanismSectionResult, calculationScenarios, failureMechanism, assessmentSection); + FailureMechanismSectionAssembly tailorMadeAssembly = AssembleTailorMadeAssessment( + failureMechanismSectionResult, failureMechanism, assessmentSection); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism to assemble for. + /// The the failure mechanism belongs to. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssembly AssembleFailureMechanism( + PipingFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + bool considerManualAssembly = true) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator sectionCalculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + AssemblyCategoriesInput assemblyCategoriesInput = CreateAssemblyCategoriesInput(failureMechanism, assessmentSection); + var sectionAssemblies = new List(); + + try + { + foreach (PipingFailureMechanismSectionResult sectionResult in failureMechanism.SectionResults) + { + if (sectionResult.UseManualAssemblyProbability && considerManualAssembly) + { + sectionAssemblies.Add(sectionCalculator.AssembleDetailedAssessment( + DetailedAssessmentProbabilityOnlyResultType.Probability, + sectionResult.ManualAssemblyProbability, + failureMechanism.PipingProbabilityAssessmentInput.GetN(sectionResult.Section.Length), + assemblyCategoriesInput)); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult, + failureMechanism.Calculations.Cast(), + failureMechanism, + assessmentSection)); + } + } + + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + return calculator.Assemble(sectionAssemblies, assemblyCategoriesInput); + } + catch (Exception e) when (e is FailureMechanismAssemblyCalculatorException || e is FailureMechanismSectionAssemblyCalculatorException) + { + throw new AssemblyException(e.Message, e); + } + } + + private static AssemblyCategoriesInput CreateAssemblyCategoriesInput(PipingFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + return new AssemblyCategoriesInput(failureMechanism.PipingProbabilityAssessmentInput.GetN( + failureMechanism.PipingProbabilityAssessmentInput.SectionLength), + failureMechanism.Contribution, + assessmentSection.FailureMechanismContribution.SignalingNorm, + assessmentSection.FailureMechanismContribution.LowerLimitNorm); + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj =================================================================== diff -u -r739752c5cc7ed800dacf74e12221c227183ddc6f -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj (.../Ringtoets.Piping.Data.csproj) (revision 739752c5cc7ed800dacf74e12221c227183ddc6f) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Ringtoets.Piping.Data.csproj (.../Ringtoets.Piping.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -14,7 +14,7 @@ - + Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs =================================================================== diff -u -r03f260e74af2da4f651a4abad32e5416999c814a -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision 03f260e74af2da4f651a4abad32e5416999c814a) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -73,7 +73,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultWithProbabilityControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(PipingFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); // The concat is needed to observe the input of calculations in child groups. calculationInputObserver = new RecursiveObserver( Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismSectionResultRow.cs =================================================================== diff -u -r4994cf24768a7b54149e65713433dc4543ace82c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismSectionResultRow.cs (.../PipingFailureMechanismSectionResultRow.cs) (revision 4994cf24768a7b54149e65713433dc4543ace82c) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismSectionResultRow.cs (.../PipingFailureMechanismSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -402,7 +402,7 @@ { try { - simpleAssemblyCategoryGroup = PipingFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; + simpleAssemblyCategoryGroup = PipingFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; } catch (AssemblyException e) { @@ -415,7 +415,7 @@ { try { - detailedAssemblyCategoryGroup = PipingFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment( + detailedAssemblyCategoryGroup = PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( SectionResult, calculations, failureMechanism, @@ -432,7 +432,7 @@ { try { - tailorMadeAssemblyCategoryGroup = PipingFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment( + tailorMadeAssemblyCategoryGroup = PipingFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -449,7 +449,7 @@ try { FailureMechanismSectionAssembly combinedAssembly = - PipingFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult, calculations, failureMechanism, Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,920 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.Data.TestUtil; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; +using Ringtoets.Piping.Data.TestUtil; + +namespace Ringtoets.Piping.Data.Test +{ + [TestFixture] + public class PipingFailureMechanismAssemblyFactoryTest + { + private static void AssertAssemblyCategoriesInput(IAssessmentSection assessmentSection, + PipingFailureMechanism failureMechanism, + AssemblyCategoriesInput assemblyCategoriesInput) + { + Assert.AreEqual(assessmentSection.FailureMechanismContribution.SignalingNorm, assemblyCategoriesInput.SignalingNorm); + Assert.AreEqual(assessmentSection.FailureMechanismContribution.LowerLimitNorm, assemblyCategoriesInput.LowerLimitNorm); + Assert.AreEqual(failureMechanism.Contribution, assemblyCategoriesInput.FailureMechanismContribution); + Assert.AreEqual(failureMechanism.PipingProbabilityAssessmentInput.GetN(failureMechanism.PipingProbabilityAssessmentInput.SectionLength), + assemblyCategoriesInput.N); + } + + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new PipingFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + PipingFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new PipingFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + PipingFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new PipingFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + null, + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_CalculationScenariosNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + new PipingFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("calculationScenarios", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + Enumerable.Empty(), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + Enumerable.Empty(), + new PipingFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + var assessmentSection = new AssessmentSectionStub(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }, true); + + var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + PipingCalculationScenario[] calculationScenarios = + { + PipingCalculationScenarioTestFactory.CreatePipingCalculationScenarioWithValidInput(hydraulicBoundaryLocation) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + calculationScenarios, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentProbabilityOnlyResultInput); + Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability( + calculationScenarios, + failureMechanism, + assessmentSection), + calculator.DetailedAssessmentProbabilityInput); + Assert.AreEqual(failureMechanism.PipingProbabilityAssessmentInput.GetN(sectionResult.Section.Length), + calculator.DetailedAssessmentNInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var assessmentSection = new AssessmentSectionStub(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }, true); + + var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + new[] + { + PipingCalculationScenarioTestFactory.CreatePipingCalculationScenarioWithValidInput(hydraulicBoundaryLocation) + }, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var assessmentSection = new AssessmentSectionStub(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }, true); + + var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + new[] + { + PipingCalculationScenarioTestFactory.CreatePipingCalculationScenarioWithValidInput(hydraulicBoundaryLocation) + }, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + null, + new PipingFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new PipingFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + PipingFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentProbability, calculator.TailorMadeAssessmentProbabilityInput); + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentProbabilityCalculationResultInput); + Assert.AreEqual(failureMechanism.PipingProbabilityAssessmentInput.GetN(sectionResult.Section.Length), + calculator.TailorMadeAssessmentNInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + PipingFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.TailorMadeAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null, + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_CalculationScenariosNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + new PipingFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("calculationScenarios", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + Enumerable.Empty(), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + Enumerable.Empty(), + new PipingFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedSimpleAssembly = PipingFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssembly expectedDetailedAssembly = PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + Enumerable.Empty(), + failureMechanism, + assessmentSection); + FailureMechanismSectionAssembly expectedTailorMadeAssembly = PipingFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + AssemblyToolTestHelper.AssertAreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.CombinedAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism( + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism( + new PipingFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + PipingFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = PipingFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + failureMechanism.SectionResults.Single(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + PipingFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection, + false); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = PipingFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssembly actualOutput = + PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + Assert.AreSame(calculator.FailureMechanismAssemblyOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj =================================================================== diff -u -r67ea037ebc9a3512d7fd4045cd968cddd3e07d4c -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 67ea037ebc9a3512d7fd4045cd968cddd3e07d4c) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -23,7 +23,7 @@ - + Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/Ringtoets.StabilityPointStructures.Data.csproj =================================================================== diff -u -r739752c5cc7ed800dacf74e12221c227183ddc6f -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/Ringtoets.StabilityPointStructures.Data.csproj (.../Ringtoets.StabilityPointStructures.Data.csproj) (revision 739752c5cc7ed800dacf74e12221c227183ddc6f) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/Ringtoets.StabilityPointStructures.Data.csproj (.../Ringtoets.StabilityPointStructures.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -23,7 +23,7 @@ - + Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,287 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.StabilityPointStructures.Data +{ + /// + /// Factory for assembling assembly results for a stability point structures failure mechanism. + /// + public static class StabilityPointStructuresFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleSimpleAssessment( + StabilityPointStructuresFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment result. + /// + /// The failure mechanism section result to + /// assemble the detailed assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleDetailedAssessment( + StabilityPointStructuresFailureMechanismSectionResult failureMechanismSectionResult, + StabilityPointStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment( + failureMechanismSectionResult.DetailedAssessmentResult, + failureMechanismSectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment result. + /// + /// The failure mechanism section result to + /// assemble the tailor made assembly for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleTailorMadeAssessment( + StabilityPointStructuresFailureMechanismSectionResult failureMechanismSectionResult, + StabilityPointStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment( + failureMechanismSectionResult.TailorMadeAssessmentResult, + failureMechanismSectionResult.TailorMadeAssessmentProbability, + CreateAssemblyCategoriesInput(failureMechanism, assessmentSection)); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assembly. + /// + /// The failure mechanism section result to + /// combine the assemblies for. + /// The failure mechanism this section belongs to. + /// The this section belongs to. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssembly AssembleCombinedAssessment( + StabilityPointStructuresFailureMechanismSectionResult failureMechanismSectionResult, + StabilityPointStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanismSectionAssembly simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssembly detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult, failureMechanism, assessmentSection); + FailureMechanismSectionAssembly tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult, failureMechanism, assessmentSection); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism to assemble for. + /// The the failure mechanism belongs to. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when any parameter is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssembly AssembleFailureMechanism( + StabilityPointStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + bool considerManualAssembly = true) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator sectionCalculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + AssemblyCategoriesInput assemblyCategoriesInput = CreateAssemblyCategoriesInput(failureMechanism, assessmentSection); + var sectionAssemblies = new List(); + + try + { + foreach (StabilityPointStructuresFailureMechanismSectionResult sectionResult in failureMechanism.SectionResults) + { + if (sectionResult.UseManualAssemblyProbability && considerManualAssembly) + { + sectionAssemblies.Add(sectionCalculator.AssembleDetailedAssessment( + DetailedAssessmentProbabilityOnlyResultType.Probability, + sectionResult.ManualAssemblyProbability, + assemblyCategoriesInput)); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult, + failureMechanism, + assessmentSection)); + } + } + + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + return calculator.Assemble(sectionAssemblies, assemblyCategoriesInput); + } + catch (Exception e) when (e is FailureMechanismAssemblyCalculatorException || e is FailureMechanismSectionAssemblyCalculatorException) + { + throw new AssemblyException(e.Message, e); + } + } + + private static AssemblyCategoriesInput CreateAssemblyCategoriesInput(StabilityPointStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + return new AssemblyCategoriesInput(failureMechanism.GeneralInput.N, + failureMechanism.Contribution, + assessmentSection.FailureMechanismContribution.SignalingNorm, + assessmentSection.FailureMechanismContribution.LowerLimitNorm); + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismResultView.cs =================================================================== diff -u -r03f260e74af2da4f651a4abad32e5416999c814a -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismResultView.cs (.../StabilityPointStructuresFailureMechanismResultView.cs) (revision 03f260e74af2da4f651a4abad32e5416999c814a) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismResultView.cs (.../StabilityPointStructuresFailureMechanismResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -76,7 +76,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultWithProbabilityControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(StabilityPointStructuresFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection))); // The concat is needed to observe the input of calculations in child groups. calculationInputObserver = new RecursiveObserver( Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -r845bc0316bfb8173d53a1d002686fc9a6a631ee1 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismSectionResultRow.cs (.../StabilityPointStructuresFailureMechanismSectionResultRow.cs) (revision 845bc0316bfb8173d53a1d002686fc9a6a631ee1) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismSectionResultRow.cs (.../StabilityPointStructuresFailureMechanismSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -364,7 +364,7 @@ { try { - simpleAssemblyCategoryGroup = StabilityPointStructuresFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; + simpleAssemblyCategoryGroup = StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult).Group; } catch (AssemblyException e) { @@ -377,7 +377,7 @@ { try { - detailedAssemblyCategoryGroup = StabilityPointStructuresFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment( + detailedAssemblyCategoryGroup = StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -393,7 +393,7 @@ { try { - tailorMadeAssemblyCategoryGroup = StabilityPointStructuresFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment( + tailorMadeAssemblyCategoryGroup = StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( SectionResult, failureMechanism, assessmentSection).Group; @@ -410,7 +410,7 @@ try { FailureMechanismSectionAssembly combinedAssembly = - StabilityPointStructuresFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult, failureMechanism, assessmentSection); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/Ringtoets.StabilityPointStructures.Data.Test.csproj =================================================================== diff -u -r2a001846d27cc4ead0a66ad14501deabb291c4f8 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/Ringtoets.StabilityPointStructures.Data.Test.csproj (.../Ringtoets.StabilityPointStructures.Data.Test.csproj) (revision 2a001846d27cc4ead0a66ad14501deabb291c4f8) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/Ringtoets.StabilityPointStructures.Data.Test.csproj (.../Ringtoets.StabilityPointStructures.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -22,7 +22,7 @@ - + Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,837 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.Data.TestUtil; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.StabilityPointStructures.Data.Test +{ + [TestFixture] + public class StabilityPointStructuresFailureMechanismAssemblyFactoryTest + { + private static void AssertAssemblyCategoriesInput(IAssessmentSection assessmentSection, + StabilityPointStructuresFailureMechanism failureMechanism, + AssemblyCategoriesInput assemblyCategoriesInput) + { + Assert.AreEqual(assessmentSection.FailureMechanismContribution.SignalingNorm, assemblyCategoriesInput.SignalingNorm); + Assert.AreEqual(assessmentSection.FailureMechanismContribution.LowerLimitNorm, assemblyCategoriesInput.LowerLimitNorm); + Assert.AreEqual(failureMechanism.Contribution, assemblyCategoriesInput.FailureMechanismContribution); + Assert.AreEqual(failureMechanism.GeneralInput.N, assemblyCategoriesInput.N); + } + + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentValidityOnlyInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + null, + new StabilityPointStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleDetailedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new StabilityPointStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + DetailedAssessmentResult = new Random(21).NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentProbabilityOnlyResultInput); + Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), + calculator.DetailedAssessmentProbabilityInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Tailor made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + null, + new StabilityPointStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleTailorMadeAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new StabilityPointStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentProbability, calculator.TailorMadeAssessmentProbabilityInput); + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentProbabilityCalculationResultInput); + AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.AssemblyCategoriesInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.TailorMadeAssessmentAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null, + new StabilityPointStructuresFailureMechanism(), + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleCombinedAssessment_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), + new StabilityPointStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedSimpleAssembly = StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssembly expectedDetailedAssembly = StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + FailureMechanismSectionAssembly expectedTailorMadeAssembly = StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + AssemblyToolTestHelper.AssertAreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyInput); + AssemblyToolTestHelper.AssertAreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyInput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssembly actualOutput = + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly calculatorOutput = calculator.CombinedAssemblyOutput; + Assert.AreSame(calculatorOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + null, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + new StabilityPointStructuresFailureMechanism(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + StabilityPointStructuresFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + StabilityPointStructuresFailureMechanismSectionResult sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.UseManualAssemblyProbability = true; + sectionResult.ManualAssemblyProbability = new Random(39).NextDouble(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection, + false); + + // Assert + FailureMechanismSectionAssembly expectedAssembly = StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + failureMechanism.SectionResults.Single(), + failureMechanism, + assessmentSection); + AssemblyToolTestHelper.AssertAreEqual(expectedAssembly, calculator.FailureMechanismSectionAssemblies.Single()); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssembly actualOutput = + StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + Assert.AreSame(calculator.FailureMechanismAssemblyOutput, actualOutput); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism( + failureMechanism, + assessmentSection); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + mocks.VerifyAll(); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/Ringtoets.StabilityStoneCover.Data.csproj =================================================================== diff -u -r015eb3822c4c4d03e957ab676e5dc4428c46f1eb -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/Ringtoets.StabilityStoneCover.Data.csproj (.../Ringtoets.StabilityStoneCover.Data.csproj) (revision 015eb3822c4c4d03e957ab676e5dc4428c46f1eb) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/Ringtoets.StabilityStoneCover.Data.csproj (.../Ringtoets.StabilityStoneCover.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -18,7 +18,7 @@ True Resources.resx - + Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,220 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; + +namespace Ringtoets.StabilityStoneCover.Data +{ + /// + /// Factory for creating assembly results for a stability stone cover failure mechanism. + /// + public static class StabilityStoneCoverFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + StabilityStoneCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment results. + /// + /// The failure mechanism section result to assemble the + /// detailed assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment( + StabilityStoneCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment(failureMechanismSectionResult.DetailedAssessmentResultForFactorizedSignalingNorm, + failureMechanismSectionResult.DetailedAssessmentResultForSignalingNorm, + failureMechanismSectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, + failureMechanismSectionResult.DetailedAssessmentResultForLowerLimitNorm, + failureMechanismSectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment results. + /// + /// The failure mechanism section result to assemble the + /// tailor made assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + StabilityStoneCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment(failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assessment results. + /// + /// The failure mechanism section result to assemble the + /// combined assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + StabilityStoneCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (StabilityStoneCoverFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Data/StabilityStoneCoverFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverResultView.cs =================================================================== diff -u -r03f260e74af2da4f651a4abad32e5416999c814a -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverResultView.cs (.../StabilityStoneCoverResultView.cs) (revision 03f260e74af2da4f651a4abad32e5416999c814a) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverResultView.cs (.../StabilityStoneCoverResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -57,7 +57,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(StabilityStoneCoverFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override StabilityStoneCoverSectionResultRow CreateFailureMechanismSectionResultRow(StabilityStoneCoverFailureMechanismSectionResult sectionResult) Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverSectionResultRow.cs =================================================================== diff -u -r845bc0316bfb8173d53a1d002686fc9a6a631ee1 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverSectionResultRow.cs (.../StabilityStoneCoverSectionResultRow.cs) (revision 845bc0316bfb8173d53a1d002686fc9a6a631ee1) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverSectionResultRow.cs (.../StabilityStoneCoverSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -358,7 +358,7 @@ { try { - simpleAssemblyCategoryGroup = StabilityStoneCoverFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -371,7 +371,7 @@ { try { - detailedAssemblyCategoryGroup = StabilityStoneCoverFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment(SectionResult); + detailedAssemblyCategoryGroup = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(SectionResult); } catch (AssemblyException e) { @@ -384,7 +384,7 @@ { try { - tailorMadeAssemblyCategoryGroup = StabilityStoneCoverFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -397,7 +397,7 @@ { try { - combinedAssemblyCategoryGroup = StabilityStoneCoverFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + combinedAssemblyCategoryGroup = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult); } catch (AssemblyException e) Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/Ringtoets.StabilityStoneCover.Data.Test.csproj =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/Ringtoets.StabilityStoneCover.Data.Test.csproj (.../Ringtoets.StabilityStoneCover.Data.Test.csproj) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/Ringtoets.StabilityStoneCover.Data.Test.csproj (.../Ringtoets.StabilityStoneCover.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -21,7 +21,7 @@ - + Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,526 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.StabilityStoneCover.Data.Test +{ + [TestFixture] + public class StabilityStoneCoverFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentValidityOnlyInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(failureMechanismSection) + { + DetailedAssessmentResultForFactorizedSignalingNorm = random.NextEnumValue(), + DetailedAssessmentResultForSignalingNorm = random.NextEnumValue(), + DetailedAssessmentResultForMechanismSpecificLowerLimitNorm = random.NextEnumValue(), + DetailedAssessmentResultForLowerLimitNorm = random.NextEnumValue(), + DetailedAssessmentResultForFactorizedLowerLimitNorm = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedSignalingNorm, calculator.DetailedAssessmentResultForFactorizedSignalingNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForSignalingNorm, calculator.DetailedAssessmentResultForSignalingNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, calculator.DetailedAssessmentResultForMechanismSpecificLowerLimitNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForLowerLimitNorm, calculator.DetailedAssessmentResultForLowerLimitNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm, calculator.DetailedAssessmentResultForFactorizedLowerLimitNormInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.DetailedAssessmentAssemblyGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(failureMechanismSection) + { + TailorMadeAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentGroupInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.TailorMadeAssemblyCategoryOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new StabilityStoneCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new StabilityStoneCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new StabilityStoneCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Data.Test/StabilityStoneCoverFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Data/Ringtoets.WaveImpactAsphaltCover.Data.csproj =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Data/Ringtoets.WaveImpactAsphaltCover.Data.csproj (.../Ringtoets.WaveImpactAsphaltCover.Data.csproj) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Data/Ringtoets.WaveImpactAsphaltCover.Data.csproj (.../Ringtoets.WaveImpactAsphaltCover.Data.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -18,7 +18,7 @@ True Resources.resx - + Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Data/WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.cs =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Data/WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.cs (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Data/WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,220 @@ +// 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 System.Collections.Generic; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.Exceptions; + +namespace Ringtoets.WaveImpactAsphaltCover.Data +{ + /// + /// Factory for creating assembly results for a wave impact asphalt cover failure mechanism. + /// + public static class WaveImpactAsphaltCoverFailureMechanismAssemblyFactory + { + /// + /// Assembles the simple assessment results. + /// + /// The failure mechanism section result to assemble the + /// simple assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment( + WaveImpactAsphaltCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group; + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the detailed assessment results. + /// + /// The failure mechanism section result to assemble the + /// detailed assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment( + WaveImpactAsphaltCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleDetailedAssessment(failureMechanismSectionResult.DetailedAssessmentResultForFactorizedSignalingNorm, + failureMechanismSectionResult.DetailedAssessmentResultForSignalingNorm, + failureMechanismSectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, + failureMechanismSectionResult.DetailedAssessmentResultForLowerLimitNorm, + failureMechanismSectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the tailor made assessment results. + /// + /// The failure mechanism section result to assemble the + /// tailor made assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment( + WaveImpactAsphaltCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleTailorMadeAssessment(failureMechanismSectionResult.TailorMadeAssessmentResult); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the combined assessment results. + /// + /// The failure mechanism section result to assemble the + /// combined assembly results for. + /// A based on the . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment( + WaveImpactAsphaltCoverFailureMechanismSectionResult failureMechanismSectionResult) + { + if (failureMechanismSectionResult == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResult)); + } + + FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = AssembleDetailedAssessment(failureMechanismSectionResult); + FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = AssembleTailorMadeAssessment(failureMechanismSectionResult); + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismSectionAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly); + } + catch (FailureMechanismSectionAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + + /// + /// Assembles the failure mechanism assembly. + /// + /// The failure mechanism section results to + /// get the assembly for. + /// Indicator whether the manual assembly should be used in the assembly. + /// A . + /// Thrown when + /// is null. + /// Thrown when the + /// could not be created. + public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism( + IEnumerable failureMechanismSectionResults, + bool considerManualAssembly = true) + { + if (failureMechanismSectionResults == null) + { + throw new ArgumentNullException(nameof(failureMechanismSectionResults)); + } + + var sectionAssemblies = new List(); + foreach (WaveImpactAsphaltCoverFailureMechanismSectionResult sectionResult in failureMechanismSectionResults) + { + if (sectionResult.UseManualAssemblyCategoryGroup && considerManualAssembly) + { + sectionAssemblies.Add(sectionResult.ManualAssemblyCategoryGroup); + } + else + { + sectionAssemblies.Add(AssembleCombinedAssessment(sectionResult)); + } + } + + IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance; + IFailureMechanismAssemblyCalculator calculator = + calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactory.Instance); + + try + { + return calculator.Assemble(sectionAssemblies); + } + catch (FailureMechanismAssemblyCalculatorException e) + { + throw new AssemblyException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Data/WaveImpactAsphaltCoverFailureMechanismSectionResultAssemblyFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismResultView.cs =================================================================== diff -u -r542840b21372104f976bd9543ca24b2122bfe424 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismResultView.cs (.../WaveImpactAsphaltCoverFailureMechanismResultView.cs) (revision 542840b21372104f976bd9543ca24b2122bfe424) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismResultView.cs (.../WaveImpactAsphaltCoverFailureMechanismResultView.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -57,7 +57,7 @@ var failureMechanismAssemblyResultWithProbabilityControl = new FailureMechanismAssemblyResultControl(); SetFailureMechanismAssemblyResultControl( failureMechanismAssemblyResultWithProbabilityControl, - () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(WaveImpactAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); + () => failureMechanismAssemblyResultWithProbabilityControl.SetAssemblyResult(WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism.SectionResults))); } protected override WaveImpactAsphaltCoverFailureMechanismSectionResultRow CreateFailureMechanismSectionResultRow( Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismSectionResultRow.cs =================================================================== diff -u -r845bc0316bfb8173d53a1d002686fc9a6a631ee1 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismSectionResultRow.cs (.../WaveImpactAsphaltCoverFailureMechanismSectionResultRow.cs) (revision 845bc0316bfb8173d53a1d002686fc9a6a631ee1) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismSectionResultRow.cs (.../WaveImpactAsphaltCoverFailureMechanismSectionResultRow.cs) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -357,7 +357,7 @@ { try { - simpleAssemblyCategoryGroup = WaveImpactAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + simpleAssemblyCategoryGroup = WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { @@ -370,7 +370,7 @@ { try { - detailedAssemblyCategoryGroup = WaveImpactAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment(SectionResult); + detailedAssemblyCategoryGroup = WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(SectionResult); } catch (AssemblyException e) { @@ -383,7 +383,7 @@ { try { - tailorMadeAssemblyCategoryGroup = WaveImpactAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); + tailorMadeAssemblyCategoryGroup = WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { @@ -396,7 +396,7 @@ { try { - combinedAssemblyCategoryGroup = WaveImpactAsphaltCoverFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( + combinedAssemblyCategoryGroup = WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( SectionResult); } catch (AssemblyException e) Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Data.Test/Ringtoets.WaveImpactAsphaltCover.Data.Test.csproj =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -rbbbfacd9e38cf43c98dba73e39694850fb932a66 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Data.Test/Ringtoets.WaveImpactAsphaltCover.Data.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.Data.Test.csproj) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Data.Test/Ringtoets.WaveImpactAsphaltCover.Data.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.Data.Test.csproj) (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -20,7 +20,7 @@ - + Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Data.Test/WaveImpactAsphaltCoverFailureMechanismAssemblyFactoryTest.cs =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Data.Test/WaveImpactAsphaltCoverFailureMechanismAssemblyFactoryTest.cs (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Data.Test/WaveImpactAsphaltCoverFailureMechanismAssemblyFactoryTest.cs (revision bbbfacd9e38cf43c98dba73e39694850fb932a66) @@ -0,0 +1,526 @@ +// 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 System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Primitives; + +namespace Ringtoets.WaveImpactAsphaltCover.Data.Test +{ + [TestFixture] + public class WaveImpactAsphaltCoverFailureMechanismAssemblyFactoryTest + { + #region Simple Assembly + + [Test] + public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(failureMechanismSection) + { + SimpleAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput); + } + } + + [Test] + public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, actualOutput); + } + } + + [Test] + public void AssembleSimpleAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Detailed Assembly + + [Test] + public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleDetailedAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(failureMechanismSection) + { + DetailedAssessmentResultForFactorizedSignalingNorm = random.NextEnumValue(), + DetailedAssessmentResultForSignalingNorm = random.NextEnumValue(), + DetailedAssessmentResultForMechanismSpecificLowerLimitNorm = random.NextEnumValue(), + DetailedAssessmentResultForLowerLimitNorm = random.NextEnumValue(), + DetailedAssessmentResultForFactorizedLowerLimitNorm = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedSignalingNorm, calculator.DetailedAssessmentResultForFactorizedSignalingNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForSignalingNorm, calculator.DetailedAssessmentResultForSignalingNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, calculator.DetailedAssessmentResultForMechanismSpecificLowerLimitNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForLowerLimitNorm, calculator.DetailedAssessmentResultForLowerLimitNormInput); + Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm, calculator.DetailedAssessmentResultForFactorizedLowerLimitNormInput); + } + } + + [Test] + public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.DetailedAssessmentAssemblyGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleDetailedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Tailor Made Assembly + + [Test] + public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleTailorMadeAssessment_WithSectionResult_SetsInputOnCalculator() + { + // Setup + var random = new Random(21); + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(failureMechanismSection) + { + TailorMadeAssessmentResult = random.NextEnumValue() + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentGroupInput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + Assert.AreEqual(calculator.TailorMadeAssemblyCategoryOutput, actualOutput); + } + } + + [Test] + public void AssembleTailorMadeAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(failureMechanismSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Combined Assembly + + [Test] + public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResult", exception.ParamName); + } + + [Test] + public void AssembleCombinedAssessment_WithInput_SetsInputOnCalculator() + { + // Setup + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly = WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment( + sectionResult); + FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment( + sectionResult); + + Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual(expectedDetailedAssembly, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput); + } + } + + [Test] + public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput() + { + // Setup + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + // Call + FailureMechanismSectionAssemblyCategoryGroup actualOutput = + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput; + Assert.AreEqual(calculatorOutput, actualOutput); + } + } + + [Test] + public void AssembleCombinedAssessment_CalculatorThrowsExceptions_ThrowsAssemblyException() + { + // Setup + var sectionResult = new WaveImpactAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculateCombinedAssembly = true; + + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + + #region Failure Mechanism Assembly + + [Test] + public void AssembleFailureMechanism_FailureMechanismSectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionResults", exception.ParamName); + } + + [Test] + public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new WaveImpactAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyTrue_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new WaveImpactAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults); + + // Assert + Assert.AreEqual(sectionResults.Single().ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_WithManualInputConsiderManualAssemblyFalse_SetsInputOnCalculator() + { + // Setup + var sectionResults = new[] + { + new WaveImpactAsphaltCoverFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) + { + UseManualAssemblyCategoryGroup = true, + ManualAssemblyCategoryGroup = new Random(39).NextEnumValue() + } + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(sectionResults, false); + + // Assert + FailureMechanismSectionAssemblyCategoryGroup assemblyCategory = + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(sectionResults.Single()); + Assert.AreEqual(assemblyCategory, calculator.FailureMechanismSectionCategories.Single()); + } + } + + [Test] + public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + + // Call + FailureMechanismAssemblyCategoryGroup actualOutput = + WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput); + } + } + + [Test] + public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException() + { + // Setup + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate call = () => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism( + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Exception innerException = exception.InnerException; + Assert.IsInstanceOf(innerException); + Assert.AreEqual(innerException.Message, exception.Message); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag bbbfacd9e38cf43c98dba73e39694850fb932a66 refers to a dead (removed) revision in file `Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Data.Test/WaveImpactAsphaltCoverFailureMechanismSectionResultAssemblyFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff?