Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismSectionListCreatorTest.cs =================================================================== diff -u -r77a4cd48837cf3f5b03973a33453fafd140a53ec -rc19058d1084b7a7f5e05e43f121f4d1c685838ad --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismSectionListCreatorTest.cs (.../FailureMechanismSectionListCreatorTest.cs) (revision 77a4cd48837cf3f5b03973a33453fafd140a53ec) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismSectionListCreatorTest.cs (.../FailureMechanismSectionListCreatorTest.cs) (revision c19058d1084b7a7f5e05e43f121f4d1c685838ad) @@ -29,6 +29,7 @@ using NUnit.Framework; using Ringtoets.AssemblyTool.Data; using Ringtoets.AssemblyTool.KernelWrapper.Creators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil; namespace Ringtoets.AssemblyTool.KernelWrapper.Test.Creators { @@ -51,25 +52,20 @@ { // Setup var random = new Random(21); - var failureMechanism = new CombinedAssemblyFailureMechanismInput(random.NextDouble(1, 2), random.NextDouble(), new[] + var combinedAssemblyFailureMechanismInputs = new[] { - new CombinedAssemblyFailureMechanismSection(0, 1, random.NextEnumValue()), - new CombinedAssemblyFailureMechanismSection(1, 2, random.NextEnumValue()) - }); + new CombinedAssemblyFailureMechanismInput(random.NextDouble(1, 2), random.NextDouble(), new[] + { + new CombinedAssemblyFailureMechanismSection(0, 1, random.NextEnumValue()), + new CombinedAssemblyFailureMechanismSection(1, 2, random.NextEnumValue()) + }) + }; // Call - FailureMechanismSectionList[] failureMechanismSectionLists = FailureMechanismSectionListCreator.Create(new[] - { - failureMechanism - }).ToArray(); + FailureMechanismSectionList[] failureMechanismSectionLists = FailureMechanismSectionListCreator.Create(combinedAssemblyFailureMechanismInputs).ToArray(); // Assert - Assert.AreEqual(1, failureMechanismSectionLists.Length); - FailureMechanismSectionList sectionList = failureMechanismSectionLists[0]; - Assert.AreEqual(failureMechanism.N, sectionList.FailureMechanism.LengthEffectFactor); - Assert.AreEqual(failureMechanism.FailureMechanismContribution, sectionList.FailureMechanism.FailureProbabilityMarginFactor); - - AssertSections(failureMechanism.Sections.ToArray(), sectionList.Results.ToArray()); + CombinedFailureMechanismSectionsInputAssert.AssertCombinedFailureMechanismInput(combinedAssemblyFailureMechanismInputs, failureMechanismSectionLists); } [Test] @@ -119,43 +115,5 @@ // Assert Assert.AreEqual(expectedGroup, ((FmSectionWithDirectCategory) output.First().Results.First()).Category); } - - private static void AssertSections(CombinedAssemblyFailureMechanismSection[] originalSections, FmSectionWithCategory[] fmSectionWithCategories) - { - Assert.AreEqual(originalSections.Length, fmSectionWithCategories.Length); - Assert.IsTrue(fmSectionWithCategories.All(r => r.GetType() == typeof(FmSectionWithDirectCategory))); - CollectionAssert.AreEqual(originalSections.Select(s => s.SectionStart), fmSectionWithCategories.Select(r => r.SectionStart)); - CollectionAssert.AreEqual(originalSections.Select(s => s.SectionEnd), fmSectionWithCategories.Select(r => r.SectionEnd)); - CollectionAssert.AreEqual(originalSections.Select(s => ConvertCategoryGroup(s.CategoryGroup)), - fmSectionWithCategories.Select(r => (FmSectionWithDirectCategory) r) - .Select(category => category.Category)); - } - - private static EFmSectionCategory ConvertCategoryGroup(FailureMechanismSectionAssemblyCategoryGroup categoryGroup) - { - switch (categoryGroup) - { - case FailureMechanismSectionAssemblyCategoryGroup.None: - return EFmSectionCategory.Gr; - case FailureMechanismSectionAssemblyCategoryGroup.NotApplicable: - return EFmSectionCategory.NotApplicable; - case FailureMechanismSectionAssemblyCategoryGroup.Iv: - return EFmSectionCategory.Iv; - case FailureMechanismSectionAssemblyCategoryGroup.IIv: - return EFmSectionCategory.IIv; - case FailureMechanismSectionAssemblyCategoryGroup.IIIv: - return EFmSectionCategory.IIIv; - case FailureMechanismSectionAssemblyCategoryGroup.IVv: - return EFmSectionCategory.IVv; - case FailureMechanismSectionAssemblyCategoryGroup.Vv: - return EFmSectionCategory.Vv; - case FailureMechanismSectionAssemblyCategoryGroup.VIv: - return EFmSectionCategory.VIv; - case FailureMechanismSectionAssemblyCategoryGroup.VIIv: - return EFmSectionCategory.VIIv; - default: - throw new NotSupportedException(); - } - } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/CombinedFailureMechanismSectionsInputAssert.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/CombinedFailureMechanismSectionsInputAssert.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/CombinedFailureMechanismSectionsInputAssert.cs (revision c19058d1084b7a7f5e05e43f121f4d1c685838ad) @@ -0,0 +1,96 @@ +// 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 Assembly.Kernel.Model; +using Assembly.Kernel.Model.FmSectionTypes; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; + +namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil +{ + /// + /// Class for asserting combined failure mechanism input. + /// + public static class CombinedFailureMechanismSectionsInputAssert + { + /// + /// Asserts whether is equal to . + /// + /// The original collection of . + /// The actual collection of . + /// Thrown when + /// is not equal to . + public static void AssertCombinedFailureMechanismInput(CombinedAssemblyFailureMechanismInput[] original, FailureMechanismSectionList[] actual) + { + Assert.AreEqual(original.Length, actual.Length); + + for (var i = 0; i < original.Length; i++) + { + CombinedAssemblyFailureMechanismInput failureMechanism = original[i]; + FailureMechanismSectionList sectionList = actual[i]; + Assert.AreEqual(failureMechanism.N, sectionList.FailureMechanism.LengthEffectFactor); + Assert.AreEqual(failureMechanism.FailureMechanismContribution, sectionList.FailureMechanism.FailureProbabilityMarginFactor); + + AssertSections(failureMechanism.Sections.ToArray(), sectionList.Results.ToArray()); + } + } + + private static void AssertSections(CombinedAssemblyFailureMechanismSection[] originalSections, FmSectionWithCategory[] fmSectionWithCategories) + { + Assert.AreEqual(originalSections.Length, fmSectionWithCategories.Length); + Assert.IsTrue(fmSectionWithCategories.All(r => r.GetType() == typeof(FmSectionWithDirectCategory))); + CollectionAssert.AreEqual(originalSections.Select(s => s.SectionStart), fmSectionWithCategories.Select(r => r.SectionStart)); + CollectionAssert.AreEqual(originalSections.Select(s => s.SectionEnd), fmSectionWithCategories.Select(r => r.SectionEnd)); + CollectionAssert.AreEqual(originalSections.Select(s => ConvertCategoryGroup(s.CategoryGroup)), + fmSectionWithCategories.Select(r => (FmSectionWithDirectCategory)r) + .Select(category => category.Category)); + } + + private static EFmSectionCategory ConvertCategoryGroup(FailureMechanismSectionAssemblyCategoryGroup categoryGroup) + { + switch (categoryGroup) + { + case FailureMechanismSectionAssemblyCategoryGroup.None: + return EFmSectionCategory.Gr; + case FailureMechanismSectionAssemblyCategoryGroup.NotApplicable: + return EFmSectionCategory.NotApplicable; + case FailureMechanismSectionAssemblyCategoryGroup.Iv: + return EFmSectionCategory.Iv; + case FailureMechanismSectionAssemblyCategoryGroup.IIv: + return EFmSectionCategory.IIv; + case FailureMechanismSectionAssemblyCategoryGroup.IIIv: + return EFmSectionCategory.IIIv; + case FailureMechanismSectionAssemblyCategoryGroup.IVv: + return EFmSectionCategory.IVv; + case FailureMechanismSectionAssemblyCategoryGroup.Vv: + return EFmSectionCategory.Vv; + case FailureMechanismSectionAssemblyCategoryGroup.VIv: + return EFmSectionCategory.VIv; + case FailureMechanismSectionAssemblyCategoryGroup.VIIv: + return EFmSectionCategory.VIIv; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj =================================================================== diff -u -r70196989bbf45e88c19faa7300c59f0b43714beb -rc19058d1084b7a7f5e05e43f121f4d1c685838ad --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision 70196989bbf45e88c19faa7300c59f0b43714beb) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision c19058d1084b7a7f5e05e43f121f4d1c685838ad) @@ -25,6 +25,7 @@ +