Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/AssemblyCalculatorInputCreator.cs =================================================================== diff -u -r46ec4eb8e77c690fb13e97fac785351a6937afd3 -r4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/AssemblyCalculatorInputCreator.cs (.../AssemblyCalculatorInputCreator.cs) (revision 46ec4eb8e77c690fb13e97fac785351a6937afd3) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/AssemblyCalculatorInputCreator.cs (.../AssemblyCalculatorInputCreator.cs) (revision 4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1) @@ -35,8 +35,8 @@ /// Creates a from a . /// /// The to create - /// a for. - /// A based on . + /// an for. + /// An based on . /// Thrown when /// is an invalid value. /// Thrown when Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionAssemblyCalculatorInputCreator.cs =================================================================== diff -u -r46ec4eb8e77c690fb13e97fac785351a6937afd3 -r4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionAssemblyCalculatorInputCreator.cs (.../FailureMechanismSectionAssemblyCalculatorInputCreator.cs) (revision 46ec4eb8e77c690fb13e97fac785351a6937afd3) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionAssemblyCalculatorInputCreator.cs (.../FailureMechanismSectionAssemblyCalculatorInputCreator.cs) (revision 4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1) @@ -39,7 +39,8 @@ /// /// Creates based on the given . /// - /// The to create the result for. + /// The to create an + /// for. /// The created . /// Thrown when /// is an invalid value. @@ -72,7 +73,8 @@ /// /// Creates based on the given . /// - /// The to create the result for. + /// The to create an + /// for. /// The created . /// Thrown when /// is an invalid value. @@ -103,7 +105,7 @@ /// /// Creates based on the given parameters. /// - /// The assembly to create + /// The to create /// a for. /// The created . /// Thrown when @@ -128,8 +130,8 @@ /// /// Creates based on the given parameters. /// - /// The category group to create - /// a for. + /// The + /// to create a for. /// The created . /// Thrown when is /// an invalid . @@ -146,15 +148,15 @@ /// /// Creates a based on the given parameters. /// - /// The detailed assessment result + /// The /// for category Iv - IIv. - /// The detailed assessment result for category + /// The for category /// IIv - IIIv. - /// The detailed assessment + /// The /// result for category IIIv - IVv. - /// The detailed assessment result for category + /// The for category /// IVv - Vv. - /// The detailed assessment result + /// The /// for category Vv - VIv. /// The created . /// Thrown when any parameter is an invalid @@ -180,7 +182,8 @@ /// /// Creates a based on the given . /// - /// The detailed assessment result to create the result for. + /// The to create an + /// for. /// The created . /// Thrown when /// is an invalid . @@ -213,7 +216,8 @@ /// /// Creates a based on the given . /// - /// The detailed assessment result to create the result for. + /// The to create an + /// for. /// The created . /// Thrown when /// is an invalid . @@ -242,7 +246,8 @@ /// /// Creates a based on the given . /// - /// The tailor made assessment result to create the result for. + /// The result to create + /// an for. /// The created . /// Thrown when /// is an invalid . @@ -277,7 +282,8 @@ /// /// Creates a based on the given . /// - /// The tailor made assessment result to create the result for. + /// The to create an + /// for. /// The created . /// Thrown when /// is an invalid . @@ -311,7 +317,8 @@ /// Creates a based on the /// given . /// - /// The tailor made assessment result to create the result for. + /// The to create an + /// for. /// The created . /// Thrown when /// is an invalid . @@ -349,7 +356,8 @@ /// /// Creates a from a . /// - /// The to create the result for. + /// The to create a + /// for. /// A based on . /// Thrown when /// is an invalid value. @@ -368,7 +376,7 @@ /// Creates a from a . /// /// The to create - /// a . + /// an . /// A based on . /// Thrown when /// is an invalid value. @@ -410,7 +418,8 @@ /// /// Creates a based on the given . /// - /// The detailed assessment result to create the category compliancy for. + /// The to create an + /// for. /// The created . /// Thrown when /// is an invalid . Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Assembly/CombinedAssemblyFailureMechanismSectionFactory.cs =================================================================== diff -u -r46ec4eb8e77c690fb13e97fac785351a6937afd3 -r4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Assembly/CombinedAssemblyFailureMechanismSectionFactory.cs (.../CombinedAssemblyFailureMechanismSectionFactory.cs) (revision 46ec4eb8e77c690fb13e97fac785351a6937afd3) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Assembly/CombinedAssemblyFailureMechanismSectionFactory.cs (.../CombinedAssemblyFailureMechanismSectionFactory.cs) (revision 4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1) @@ -138,7 +138,7 @@ } GrassCoverSlipOffInwardsFailureMechanism grassCoverSlipOffInwardsFailureMechanism = assessmentSection.GrassCoverSlipOffInwards; - if (failureMechanisms.Contains(grassCoverSlipOffOutwardsFailureMechanism)) + if (failureMechanisms.Contains(grassCoverSlipOffInwardsFailureMechanism)) { inputs.Add(CreateCombinedSections(grassCoverSlipOffInwardsFailureMechanism.SectionResults, GrassCoverSlipOffInwardsAssemblyFunc)); Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Assembly/CombinedAssemblyFailureMechanismSectionFactoryTest.cs =================================================================== diff -u -r46ec4eb8e77c690fb13e97fac785351a6937afd3 -r4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Assembly/CombinedAssemblyFailureMechanismSectionFactoryTest.cs (.../CombinedAssemblyFailureMechanismSectionFactoryTest.cs) (revision 46ec4eb8e77c690fb13e97fac785351a6937afd3) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Assembly/CombinedAssemblyFailureMechanismSectionFactoryTest.cs (.../CombinedAssemblyFailureMechanismSectionFactoryTest.cs) (revision 4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1) @@ -23,9 +23,12 @@ using System.Collections.Generic; using System.Linq; using Core.Common.TestUtil; +using Core.Common.Util.Extensions; using NUnit.Framework; using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Integration.Data.Assembly; @@ -76,27 +79,74 @@ // Assert Assert.AreEqual(18, inputs.Count()); - AssertSections(assessmentSection.Piping.SectionResults, inputs.ElementAt(0)); - AssertSections(assessmentSection.GrassCoverErosionInwards.SectionResults, inputs.ElementAt(1)); - AssertSections(assessmentSection.MacroStabilityInwards.SectionResults, inputs.ElementAt(2)); - AssertSections(assessmentSection.MacroStabilityOutwards.SectionResults, inputs.ElementAt(3)); - AssertSections(assessmentSection.Microstability.SectionResults, inputs.ElementAt(4)); - AssertSections(assessmentSection.StabilityStoneCover.SectionResults, inputs.ElementAt(5)); - AssertSections(assessmentSection.WaveImpactAsphaltCover.SectionResults, inputs.ElementAt(6)); - AssertSections(assessmentSection.WaterPressureAsphaltCover.SectionResults, inputs.ElementAt(7)); - AssertSections(assessmentSection.GrassCoverErosionOutwards.SectionResults, inputs.ElementAt(8)); - AssertSections(assessmentSection.GrassCoverSlipOffOutwards.SectionResults, inputs.ElementAt(9)); - AssertSections(assessmentSection.GrassCoverSlipOffInwards.SectionResults, inputs.ElementAt(10)); - AssertSections(assessmentSection.HeightStructures.SectionResults, inputs.ElementAt(11)); - AssertSections(assessmentSection.ClosingStructures.SectionResults, inputs.ElementAt(12)); - AssertSections(assessmentSection.PipingStructure.SectionResults, inputs.ElementAt(13)); - AssertSections(assessmentSection.StabilityPointStructures.SectionResults, inputs.ElementAt(14)); - AssertSections(assessmentSection.StrengthStabilityLengthwiseConstruction.SectionResults, inputs.ElementAt(15)); - AssertSections(assessmentSection.DuneErosion.SectionResults, inputs.ElementAt(16)); - AssertSections(assessmentSection.TechnicalInnovation.SectionResults, inputs.ElementAt(17)); + AssertSectionsWithResult(assessmentSection.Piping.SectionResults, inputs.ElementAt(0)); + AssertSectionsWithResult(assessmentSection.GrassCoverErosionInwards.SectionResults, inputs.ElementAt(1)); + AssertSectionsWithResult(assessmentSection.MacroStabilityInwards.SectionResults, inputs.ElementAt(2)); + AssertSectionsWithResult(assessmentSection.MacroStabilityOutwards.SectionResults, inputs.ElementAt(3)); + AssertSectionsWithResult(assessmentSection.Microstability.SectionResults, inputs.ElementAt(4)); + AssertSectionsWithResult(assessmentSection.StabilityStoneCover.SectionResults, inputs.ElementAt(5)); + AssertSectionsWithResult(assessmentSection.WaveImpactAsphaltCover.SectionResults, inputs.ElementAt(6)); + AssertSectionsWithResult(assessmentSection.WaterPressureAsphaltCover.SectionResults, inputs.ElementAt(7)); + AssertSectionsWithResult(assessmentSection.GrassCoverErosionOutwards.SectionResults, inputs.ElementAt(8)); + AssertSectionsWithResult(assessmentSection.GrassCoverSlipOffOutwards.SectionResults, inputs.ElementAt(9)); + AssertSectionsWithResult(assessmentSection.GrassCoverSlipOffInwards.SectionResults, inputs.ElementAt(10)); + AssertSectionsWithResult(assessmentSection.HeightStructures.SectionResults, inputs.ElementAt(11)); + AssertSectionsWithResult(assessmentSection.ClosingStructures.SectionResults, inputs.ElementAt(12)); + AssertSectionsWithResult(assessmentSection.PipingStructure.SectionResults, inputs.ElementAt(13)); + AssertSectionsWithResult(assessmentSection.StabilityPointStructures.SectionResults, inputs.ElementAt(14)); + AssertSectionsWithResult(assessmentSection.StrengthStabilityLengthwiseConstruction.SectionResults, inputs.ElementAt(15)); + AssertSectionsWithResult(assessmentSection.DuneErosion.SectionResults, inputs.ElementAt(16)); + AssertSectionsWithResult(assessmentSection.TechnicalInnovation.SectionResults, inputs.ElementAt(17)); } } + [Test] + [TestCaseSource(nameof(GetFailureMechanismTestCaseData))] + public void CreateInput_WithOneFailureMechanism_ReturnsInputCollection(AssessmentSection assessmentSection, IFailureMechanism relevantFailureMechanism) + { + // Setup + assessmentSection.GetFailureMechanisms().ForEachElementDo(failureMechanism => failureMechanism.IsRelevant = failureMechanism == relevantFailureMechanism); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + // Call + IEnumerable> inputs = CombinedAssemblyFailureMechanismSectionFactory.CreateInput( + assessmentSection, new[] + { + relevantFailureMechanism + }); + + // Assert + Assert.AreEqual(1, inputs.Count()); + AssertSections(((IHasSectionResults) relevantFailureMechanism).SectionResults, inputs.ElementAt(0)); + } + } + + private static IEnumerable GetFailureMechanismTestCaseData() + { + AssessmentSection assessmentSection = TestDataGenerator.GetAssessmenSectionWithAllFailureMechanismSectionsAndResults( + new Random(21).NextEnumValue()); + + yield return new TestCaseData(assessmentSection, assessmentSection.Piping); + yield return new TestCaseData(assessmentSection, assessmentSection.GrassCoverErosionInwards); + yield return new TestCaseData(assessmentSection, assessmentSection.MacroStabilityInwards); + yield return new TestCaseData(assessmentSection, assessmentSection.MacroStabilityOutwards); + yield return new TestCaseData(assessmentSection, assessmentSection.Microstability); + yield return new TestCaseData(assessmentSection, assessmentSection.StabilityStoneCover); + yield return new TestCaseData(assessmentSection, assessmentSection.WaveImpactAsphaltCover); + yield return new TestCaseData(assessmentSection, assessmentSection.WaterPressureAsphaltCover); + yield return new TestCaseData(assessmentSection, assessmentSection.GrassCoverErosionOutwards); + yield return new TestCaseData(assessmentSection, assessmentSection.GrassCoverSlipOffOutwards); + yield return new TestCaseData(assessmentSection, assessmentSection.GrassCoverSlipOffInwards); + yield return new TestCaseData(assessmentSection, assessmentSection.HeightStructures); + yield return new TestCaseData(assessmentSection, assessmentSection.ClosingStructures); + yield return new TestCaseData(assessmentSection, assessmentSection.PipingStructure); + yield return new TestCaseData(assessmentSection, assessmentSection.StabilityPointStructures); + yield return new TestCaseData(assessmentSection, assessmentSection.StrengthStabilityLengthwiseConstruction); + yield return new TestCaseData(assessmentSection, assessmentSection.DuneErosion); + yield return new TestCaseData(assessmentSection, assessmentSection.TechnicalInnovation); + } + private static void AssertSections(IEnumerable originalSectionResults, IEnumerable inputSections) where T : FailureMechanismSectionResult { @@ -110,10 +160,20 @@ Assert.AreEqual(expectedSectionStart, inputSections.ElementAt(i).SectionStart); Assert.AreEqual(expectedSectionEnd, inputSections.ElementAt(i).SectionEnd); - Assert.AreEqual(FailureMechanismSectionAssemblyCategoryGroup.VIv, inputSections.ElementAt(i).CategoryGroup); expectedSectionStart = expectedSectionEnd; } } + + private static void AssertSectionsWithResult(IEnumerable originalSectionResults, IEnumerable inputSections) + where T : FailureMechanismSectionResult + { + AssertSections(originalSectionResults, inputSections); + + for (var i = 0; i < originalSectionResults.Count(); i++) + { + Assert.AreEqual(FailureMechanismSectionAssemblyCategoryGroup.VIv, inputSections.ElementAt(i).CategoryGroup); + } + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.TestUtil.Test/TestDataGeneratorTest.cs =================================================================== diff -u -r1226447b1a4b2e83dff18412e7f5a9cfa5b44f53 -r4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1 --- Ringtoets/Integration/test/Ringtoets.Integration.TestUtil.Test/TestDataGeneratorTest.cs (.../TestDataGeneratorTest.cs) (revision 1226447b1a4b2e83dff18412e7f5a9cfa5b44f53) +++ Ringtoets/Integration/test/Ringtoets.Integration.TestUtil.Test/TestDataGeneratorTest.cs (.../TestDataGeneratorTest.cs) (revision 4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1) @@ -173,9 +173,10 @@ new Point2D(-3, 2) }, assessmentSection.ReferenceLine.Points); - foreach (IFailureMechanism failureMechanism in assessmentSection.GetFailureMechanisms()) + IEnumerable failureMechanisms = assessmentSection.GetFailureMechanisms(); + for (int i = 0; i < failureMechanisms.Count(); i++) { - AssertHasFailureMechanismSections(failureMechanism); + AssertHasFailureMechanismSections(failureMechanisms.ElementAt(i), i); } } @@ -386,6 +387,33 @@ } } + private static void AssertHasFailureMechanismSections(IFailureMechanism failureMechanism, int sectionsCount) + { + IEnumerable sections = failureMechanism.Sections; + Assert.AreEqual(sectionsCount, sections.Count()); + + var startPoint = new Point2D(-1, -1); + var endPoint = new Point2D(15, 15); + double endPointStepsX = (endPoint.X - startPoint.X) / sectionsCount; + double endPointStepsY = (endPoint.Y - startPoint.Y) / sectionsCount; + + for (var i = 1; i <= sectionsCount; i++) + { + endPoint = new Point2D(startPoint.X + endPointStepsX, startPoint.Y + endPointStepsY); + FailureMechanismSection currentSection = sections.ElementAt(i-1); + Assert.AreEqual(currentSection.StartPoint, startPoint); + Assert.AreEqual(currentSection.EndPoint, endPoint); + + startPoint = endPoint; + } + + var failureMechanismHasSectionResults = failureMechanism as IHasSectionResults; + if (failureMechanismHasSectionResults != null) + { + Assert.AreEqual(sections.Count(), failureMechanismHasSectionResults.SectionResults.Count()); + } + } + #region Grass Cover Erosion Inwards [Test] Index: Ringtoets/Integration/test/Ringtoets.Integration.TestUtil/TestDataGenerator.cs =================================================================== diff -u -rb4ef5ef0339a13b0996d567c6d4347c4441a62cc -r4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1 --- Ringtoets/Integration/test/Ringtoets.Integration.TestUtil/TestDataGenerator.cs (.../TestDataGenerator.cs) (revision b4ef5ef0339a13b0996d567c6d4347c4441a62cc) +++ Ringtoets/Integration/test/Ringtoets.Integration.TestUtil/TestDataGenerator.cs (.../TestDataGenerator.cs) (revision 4346ce5754a1bf0bc10aaf5bd24d1a2f487acab1) @@ -243,9 +243,10 @@ ReferenceLine = GetReferenceLine() }; - foreach (IFailureMechanism failureMechanism in assessmentSection.GetFailureMechanisms()) + IEnumerable failureMechanisms = assessmentSection.GetFailureMechanisms(); + for (var i = 0; i < failureMechanisms.Count(); i++) { - AddFailureMechanismSections(failureMechanism); + AddFailureMechanismSections(failureMechanisms.ElementAt(i), i); } return assessmentSection; @@ -1071,5 +1072,25 @@ failureMechanism.AddSection(section1); failureMechanism.AddSection(section2); } + + private static void AddFailureMechanismSections(IFailureMechanism failureMechanism, int numberOfSections) + { + var startPoint = new Point2D(-1, -1); + var endPoint = new Point2D(15, 15); + double endPointStepsX = (endPoint.X - startPoint.X) / numberOfSections; + double endPointStepsY = (endPoint.Y - startPoint.Y) / numberOfSections; + + for (var i = 1; i <= numberOfSections; i++) + { + endPoint = new Point2D(startPoint.X + endPointStepsX, startPoint.Y + endPointStepsY); + failureMechanism.AddSection(new FailureMechanismSection(i.ToString(), + new [] + { + startPoint, + endPoint + })); + startPoint = endPoint; + } + } } } \ No newline at end of file