Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/AssessmentSectionAssemblyCalculator.cs
===================================================================
diff -u -rdb2a21e6d5285bfd38f4797c30ed4d7c71b3215e -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/AssessmentSectionAssemblyCalculator.cs (.../AssessmentSectionAssemblyCalculator.cs) (revision db2a21e6d5285bfd38f4797c30ed4d7c71b3215e)
+++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/AssessmentSectionAssemblyCalculator.cs (.../AssessmentSectionAssemblyCalculator.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -115,7 +115,7 @@
ICommonFailureMechanismSectionAssembler kernel = factory.CreateCombinedFailureMechanismSectionAssemblyKernel();
AssemblyResult output = kernel.AssembleCommonFailureMechanismSections(FailureMechanismSectionListCreator.Create(input), assessmentSectionLength, false);
- return CombinedFailureMechanismSectionAssemblyCreator.Create(output).ToArray();
+ return CombinedFailureMechanismSectionAssemblyCreator.Create(output);
}
catch (Exception e)
{
Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/AssemblyCalculatorInputCreator.cs
===================================================================
diff -u
--- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/AssemblyCalculatorInputCreator.cs (revision 0)
+++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/AssemblyCalculatorInputCreator.cs (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -0,0 +1,79 @@
+// 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.ComponentModel;
+using Assembly.Kernel.Model.FmSectionTypes;
+using Ringtoets.AssemblyTool.Data;
+
+namespace Ringtoets.AssemblyTool.KernelWrapper.Creators
+{
+ ///
+ /// Creates input instances that can be used in the assembly kernel.
+ ///
+ internal static class AssemblyCalculatorInputCreator
+ {
+ ///
+ /// Creates a from a .
+ ///
+ /// The to create
+ /// a .
+ /// A based on .
+ /// Thrown when
+ /// is an invalid value.
+ /// Thrown when
+ /// is a valid value, but unsupported.
+ public static EFmSectionCategory CreateFailureMechanismSectionCategory(
+ FailureMechanismSectionAssemblyCategoryGroup category)
+ {
+ if (!Enum.IsDefined(typeof(FailureMechanismSectionAssemblyCategoryGroup), category))
+ {
+ throw new InvalidEnumArgumentException(nameof(category),
+ (int) category,
+ typeof(FailureMechanismSectionAssemblyCategoryGroup));
+ }
+
+ switch (category)
+ {
+ 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;
+ case FailureMechanismSectionAssemblyCategoryGroup.NotApplicable:
+ return EFmSectionCategory.NotApplicable;
+ case FailureMechanismSectionAssemblyCategoryGroup.None:
+ return EFmSectionCategory.Gr;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionAssemblyCalculatorInputCreator.cs
===================================================================
diff -u -r5054dd8dca09c2c282b4c7aaccd4214c18413cd1 -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionAssemblyCalculatorInputCreator.cs (.../FailureMechanismSectionAssemblyCalculatorInputCreator.cs) (revision 5054dd8dca09c2c282b4c7aaccd4214c18413cd1)
+++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionAssemblyCalculatorInputCreator.cs (.../FailureMechanismSectionAssemblyCalculatorInputCreator.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -121,8 +121,7 @@
throw new ArgumentNullException(nameof(assembly));
}
- return new FmSectionAssemblyDirectResult(
- CreateFailureMechanismSectionCategory(assembly.Group),
+ return new FmSectionAssemblyDirectResult(AssemblyCalculatorInputCreator.CreateFailureMechanismSectionCategory(assembly.Group),
assembly.Probability);
}
@@ -141,7 +140,7 @@
public static FmSectionAssemblyDirectResult CreateFailureMechanismSectionAssemblyDirectResult(
FailureMechanismSectionAssemblyCategoryGroup categoryGroup)
{
- return new FmSectionAssemblyDirectResult(CreateFailureMechanismSectionCategory(categoryGroup));
+ return new FmSectionAssemblyDirectResult(AssemblyCalculatorInputCreator.CreateFailureMechanismSectionCategory(categoryGroup));
}
///
@@ -366,51 +365,6 @@
}
///
- /// Creates a from a .
- ///
- /// The to create
- /// a .
- /// A based on .
- /// Thrown when
- /// is an invalid value.
- /// Thrown when
- /// is a valid value, but unsupported.
- private static EFmSectionCategory CreateFailureMechanismSectionCategory(
- FailureMechanismSectionAssemblyCategoryGroup category)
- {
- if (!Enum.IsDefined(typeof(FailureMechanismSectionAssemblyCategoryGroup), category))
- {
- throw new InvalidEnumArgumentException(nameof(category),
- (int) category,
- typeof(FailureMechanismSectionAssemblyCategoryGroup));
- }
-
- switch (category)
- {
- 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;
- case FailureMechanismSectionAssemblyCategoryGroup.NotApplicable:
- return EFmSectionCategory.NotApplicable;
- case FailureMechanismSectionAssemblyCategoryGroup.None:
- return EFmSectionCategory.Gr;
- default:
- throw new NotSupportedException();
- }
- }
-
- ///
/// Creates a from a .
///
/// The to create
Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionListCreator.cs
===================================================================
diff -u -rdb2a21e6d5285bfd38f4797c30ed4d7c71b3215e -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionListCreator.cs (.../FailureMechanismSectionListCreator.cs) (revision db2a21e6d5285bfd38f4797c30ed4d7c71b3215e)
+++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionListCreator.cs (.../FailureMechanismSectionListCreator.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -43,6 +43,10 @@
/// A collection of .
/// Thrown when
/// is null.
+ /// Thrown when
+ /// is an invalid value.
+ /// Thrown when
+ /// is a valid value, but unsupported.
public static IEnumerable Create(
IEnumerable> failureMechanismSectionsCollection)
{
@@ -55,42 +59,9 @@
new FailureMechanism(1, 0),
sectionCollection.Select(s => new FmSectionWithDirectCategory(
s.SectionStart, s.SectionEnd,
- ConvertCategoryGroup(s.CategoryGroup)))))
+ AssemblyCalculatorInputCreator.CreateFailureMechanismSectionCategory(
+ s.CategoryGroup)))))
.ToArray();
}
-
- private static EFmSectionCategory ConvertCategoryGroup(FailureMechanismSectionAssemblyCategoryGroup category)
- {
- if (!Enum.IsDefined(typeof(FailureMechanismSectionAssemblyCategoryGroup), category))
- {
- throw new InvalidEnumArgumentException(nameof(category),
- (int) category,
- typeof(FailureMechanismSectionAssemblyCategoryGroup));
- }
-
- switch (category)
- {
- 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/src/Ringtoets.AssemblyTool.KernelWrapper/Ringtoets.AssemblyTool.KernelWrapper.csproj
===================================================================
diff -u -r77a4cd48837cf3f5b03973a33453fafd140a53ec -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Ringtoets.AssemblyTool.KernelWrapper.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.csproj) (revision 77a4cd48837cf3f5b03973a33453fafd140a53ec)
+++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Ringtoets.AssemblyTool.KernelWrapper.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.csproj) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -27,6 +27,7 @@
+
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorTest.cs
===================================================================
diff -u -rdb2a21e6d5285bfd38f4797c30ed4d7c71b3215e -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorTest.cs (.../AssessmentSectionAssemblyCalculatorTest.cs) (revision db2a21e6d5285bfd38f4797c30ed4d7c71b3215e)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorTest.cs (.../AssessmentSectionAssemblyCalculatorTest.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -557,7 +557,7 @@
// Assert
Assert.AreEqual(assessmentSectionLength, kernel.AssessmentSectionLengthInput.Value);
- CombinedFailureMechanismSectionsInputAssert.AssertCombinedFailureMechanismInput(input, kernel.FailureMechanismSectionListsInput.ToArray());
+ CombinedFailureMechanismSectionsInputAssert.AssertCombinedFailureMechanismInput(input, kernel.FailureMechanismSectionListsInput);
Assert.IsFalse(kernel.PartialAssembly);
}
}
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorTest.cs
===================================================================
diff -u -r7c355e20c39e28c6837702bbbf7dcfea5cae6c7b -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorTest.cs (.../FailureMechanismSectionAssemblyCalculatorTest.cs) (revision 7c355e20c39e28c6837702bbbf7dcfea5cae6c7b)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorTest.cs (.../FailureMechanismSectionAssemblyCalculatorTest.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -32,6 +32,7 @@
using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly;
using Ringtoets.AssemblyTool.KernelWrapper.Creators;
using Ringtoets.AssemblyTool.KernelWrapper.Kernels;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil;
using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels;
using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assembly;
using Ringtoets.Common.Primitives;
@@ -70,37 +71,10 @@
private static void AssertCalculatorOutput(FmSectionAssemblyDirectResult original, FailureMechanismSectionAssembly actual)
{
- Assert.AreEqual(GetGroup(original.Result), actual.Group);
+ Assert.AreEqual(AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(original.Result), actual.Group);
Assert.AreEqual(original.FailureProbability, actual.Probability);
}
- private static FailureMechanismSectionAssemblyCategoryGroup GetGroup(EFmSectionCategory originalGroup)
- {
- switch (originalGroup)
- {
- case EFmSectionCategory.Iv:
- return FailureMechanismSectionAssemblyCategoryGroup.Iv;
- case EFmSectionCategory.IIv:
- return FailureMechanismSectionAssemblyCategoryGroup.IIv;
- case EFmSectionCategory.IIIv:
- return FailureMechanismSectionAssemblyCategoryGroup.IIIv;
- case EFmSectionCategory.IVv:
- return FailureMechanismSectionAssemblyCategoryGroup.IVv;
- case EFmSectionCategory.Vv:
- return FailureMechanismSectionAssemblyCategoryGroup.Vv;
- case EFmSectionCategory.VIv:
- return FailureMechanismSectionAssemblyCategoryGroup.VIv;
- case EFmSectionCategory.VIIv:
- return FailureMechanismSectionAssemblyCategoryGroup.VIIv;
- case EFmSectionCategory.Gr:
- return FailureMechanismSectionAssemblyCategoryGroup.None;
- case EFmSectionCategory.NotApplicable:
- return FailureMechanismSectionAssemblyCategoryGroup.NotApplicable;
- default:
- throw new NotSupportedException();
- }
- }
-
private static void AssertAssemblyCategoriesInput(AssemblyCategoriesInput assemblyCategoriesInput, FailureMechanismSectionAssemblyKernelStub kernel)
{
Assert.AreEqual(assemblyCategoriesInput.N, kernel.FailureMechanismInput.LengthEffectFactor);
@@ -443,7 +417,9 @@
random.NextEnumValue());
// Assert
- Assert.AreEqual(GetGroup(kernel.FailureMechanismSectionDirectResult.Result), assembly);
+ FailureMechanismSectionAssemblyCategoryGroup expectedResult = AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(
+ kernel.FailureMechanismSectionDirectResult.Result);
+ Assert.AreEqual(expectedResult, assembly);
}
}
@@ -525,7 +501,7 @@
EAssessmentResultTypeG2 expectedResultType = FailureMechanismSectionAssemblyCalculatorInputCreator.CreateAssessmentResultTypeG2(detailedAssessment);
Assert.AreEqual(expectedResultType, kernel.AssessmentResultTypeG2Input);
Assert.AreEqual(probability, kernel.FailureProbabilityInput);
-
+
AssertAssemblyCategoriesInput(assemblyCategoriesInput, kernel);
}
}
@@ -935,7 +911,9 @@
random.NextEnumValue());
// Assert
- Assert.AreEqual(GetGroup(kernel.FailureMechanismSectionDirectResult.Result), assembly);
+ FailureMechanismSectionAssemblyCategoryGroup expectedResult = AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(
+ kernel.FailureMechanismSectionDirectResult.Result);
+ Assert.AreEqual(expectedResult, assembly);
}
}
@@ -1079,7 +1057,9 @@
random.NextEnumValue());
// Assert
- Assert.AreEqual(GetGroup(kernel.FailureMechanismSectionDirectResult.Result), assembly);
+ FailureMechanismSectionAssemblyCategoryGroup expectedResult = AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(
+ kernel.FailureMechanismSectionDirectResult.Result);
+ Assert.AreEqual(expectedResult, assembly);
}
}
@@ -1667,7 +1647,9 @@
random.NextEnumValue());
// Assert
- Assert.AreEqual(GetGroup(kernel.FailureMechanismSectionDirectResult.Result), assembly);
+ FailureMechanismSectionAssemblyCategoryGroup expectedResult = AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(
+ kernel.FailureMechanismSectionDirectResult.Result);
+ Assert.AreEqual(expectedResult, assembly);
}
}
@@ -1937,9 +1919,9 @@
calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly);
// Assert
- Assert.AreEqual(simpleAssembly, GetGroup(kernel.SimpleAssessmentResultInput.Result));
- Assert.AreEqual(detailedAssembly, GetGroup(kernel.DetailedAssessmentResultInput.Result));
- Assert.AreEqual(tailorMadeAssembly, GetGroup(kernel.TailorMadeAssessmentResultInput.Result));
+ Assert.AreEqual(simpleAssembly, AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(kernel.SimpleAssessmentResultInput.Result));
+ Assert.AreEqual(detailedAssembly, AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(kernel.DetailedAssessmentResultInput.Result));
+ Assert.AreEqual(tailorMadeAssembly, AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(kernel.TailorMadeAssessmentResultInput.Result));
}
}
@@ -1967,7 +1949,8 @@
calculator.AssembleCombined(simpleAssembly, detailedAssembly, tailorMadeAssembly);
// Assert
- Assert.AreEqual(simpleAssembly, GetGroup(kernel.SimpleAssessmentResultInput.Result));
+
+ Assert.AreEqual(simpleAssembly, AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(kernel.SimpleAssessmentResultInput.Result));
Assert.IsNull(kernel.DetailedAssessmentResultInput);
Assert.IsNull(kernel.TailorMadeAssessmentResultInput);
}
@@ -1994,7 +1977,9 @@
random.NextEnumValue());
// Assert
- Assert.AreEqual(GetGroup(kernel.FailureMechanismSectionDirectResult.Result), group);
+ FailureMechanismSectionAssemblyCategoryGroup expectedResult = AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(
+ kernel.FailureMechanismSectionDirectResult.Result);
+ Assert.AreEqual(expectedResult, group);
}
}
@@ -2057,7 +2042,7 @@
private static void AssertAssembly(FailureMechanismSectionAssembly assembly, FmSectionAssemblyDirectResult kernelAssemblyResult)
{
Assert.AreEqual(assembly.Probability, kernelAssemblyResult.FailureProbability ?? double.NaN);
- Assert.AreEqual(assembly.Group, GetGroup(kernelAssemblyResult.Result));
+ Assert.AreEqual(assembly.Group, AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(kernelAssemblyResult.Result));
}
#endregion
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/AssemblyCalculatorInputCreatorTest.cs
===================================================================
diff -u
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/AssemblyCalculatorInputCreatorTest.cs (revision 0)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/AssemblyCalculatorInputCreatorTest.cs (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -0,0 +1,68 @@
+// 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.ComponentModel;
+using Assembly.Kernel.Model.FmSectionTypes;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.KernelWrapper.Creators;
+
+namespace Ringtoets.AssemblyTool.KernelWrapper.Test.Creators
+{
+ [TestFixture]
+ public class AssemblyCalculatorInputCreatorTest
+ {
+ [Test]
+ public void CreateFailureMechanismSectionCategory_WithInvalidEnumInput_ThrowInvalidEnumArgumentException()
+ {
+ // Call
+ TestDelegate test = () => AssemblyCalculatorInputCreator.CreateFailureMechanismSectionCategory(
+ (FailureMechanismSectionAssemblyCategoryGroup) 99);
+
+ // Assert
+ string expectedMessage = $"The value of argument 'category' (99) is invalid for Enum type '{nameof(FailureMechanismSectionAssemblyCategoryGroup)}'.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ }
+
+ [Test]
+ [TestCase(FailureMechanismSectionAssemblyCategoryGroup.NotApplicable, EFmSectionCategory.NotApplicable)]
+ [TestCase(FailureMechanismSectionAssemblyCategoryGroup.None, EFmSectionCategory.Gr)]
+ [TestCase(FailureMechanismSectionAssemblyCategoryGroup.Iv, EFmSectionCategory.Iv)]
+ [TestCase(FailureMechanismSectionAssemblyCategoryGroup.IIv, EFmSectionCategory.IIv)]
+ [TestCase(FailureMechanismSectionAssemblyCategoryGroup.IIIv, EFmSectionCategory.IIIv)]
+ [TestCase(FailureMechanismSectionAssemblyCategoryGroup.IVv, EFmSectionCategory.IVv)]
+ [TestCase(FailureMechanismSectionAssemblyCategoryGroup.Vv, EFmSectionCategory.Vv)]
+ [TestCase(FailureMechanismSectionAssemblyCategoryGroup.VIv, EFmSectionCategory.VIv)]
+ [TestCase(FailureMechanismSectionAssemblyCategoryGroup.VIIv, EFmSectionCategory.VIIv)]
+ public void CreateFailureMechanismSectionCategory_WithValidGroup_ReturnEFmSectionCategory(
+ FailureMechanismSectionAssemblyCategoryGroup originalGroup,
+ EFmSectionCategory expectedGroup)
+ {
+ // Call
+ EFmSectionCategory actualGroup = AssemblyCalculatorInputCreator.CreateFailureMechanismSectionCategory(
+ originalGroup);
+
+ // Assert
+ Assert.AreEqual(expectedGroup, actualGroup);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/CombinedFailureMechanismSectionAssemblyCreatorTest.cs
===================================================================
diff -u -ra76570f47dca0e8a8eb8a3792f44c82a55dcc5ac -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/CombinedFailureMechanismSectionAssemblyCreatorTest.cs (.../CombinedFailureMechanismSectionAssemblyCreatorTest.cs) (revision a76570f47dca0e8a8eb8a3792f44c82a55dcc5ac)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/CombinedFailureMechanismSectionAssemblyCreatorTest.cs (.../CombinedFailureMechanismSectionAssemblyCreatorTest.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.Linq;
using Assembly.Kernel.Model;
using Assembly.Kernel.Model.FmSectionTypes;
@@ -74,7 +75,7 @@
})
};
- var combinedResults = new[]
+ FmSectionWithDirectCategory[] combinedResults =
{
CreateCategory(sections[0], random),
CreateCategory(sections[1], random),
@@ -84,7 +85,7 @@
var assembly = new AssemblyResult(failureMechanismResults, combinedResults);
// Call
- CombinedFailureMechanismSectionAssembly[] results = CombinedFailureMechanismSectionAssemblyCreator.Create(assembly).ToArray();
+ IEnumerable results = CombinedFailureMechanismSectionAssemblyCreator.Create(assembly);
// Assert
CombinedFailureMechanismSectionAssemblyAssert.AssertAssembly(assembly, results);
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismSectionListCreatorTest.cs
===================================================================
diff -u -rdb2a21e6d5285bfd38f4797c30ed4d7c71b3215e -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismSectionListCreatorTest.cs (.../FailureMechanismSectionListCreatorTest.cs) (revision db2a21e6d5285bfd38f4797c30ed4d7c71b3215e)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismSectionListCreatorTest.cs (.../FailureMechanismSectionListCreatorTest.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -62,7 +62,7 @@
};
// Call
- FailureMechanismSectionList[] failureMechanismSectionLists = FailureMechanismSectionListCreator.Create(combinedAssemblyFailureMechanismInputs).ToArray();
+ IEnumerable failureMechanismSectionLists = FailureMechanismSectionListCreator.Create(combinedAssemblyFailureMechanismInputs);
// Assert
CombinedFailureMechanismSectionsInputAssert.AssertCombinedFailureMechanismInput(combinedAssemblyFailureMechanismInputs, failureMechanismSectionLists);
@@ -107,7 +107,7 @@
});
// Assert
- Assert.AreEqual(expectedGroup, ((FmSectionWithDirectCategory) output.First().Results.First()).Category);
+ Assert.AreEqual(expectedGroup, ((FmSectionWithDirectCategory) output.Single().Results.Single()).Category);
}
}
}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Ringtoets.AssemblyTool.KernelWrapper.Test.csproj
===================================================================
diff -u -r77a4cd48837cf3f5b03973a33453fafd140a53ec -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Ringtoets.AssemblyTool.KernelWrapper.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.Test.csproj) (revision 77a4cd48837cf3f5b03973a33453fafd140a53ec)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Ringtoets.AssemblyTool.KernelWrapper.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.Test.csproj) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -29,6 +29,7 @@
+
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/AssemblyCategoryAssert.cs
===================================================================
diff -u -r2f05c299a43f2b890e0276cf74078c616a3ca27d -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/AssemblyCategoryAssert.cs (.../AssemblyCategoryAssert.cs) (revision 2f05c299a43f2b890e0276cf74078c616a3ca27d)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/AssemblyCategoryAssert.cs (.../AssemblyCategoryAssert.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -86,6 +86,41 @@
CollectionAssert.AreEqual(original.Select(o => o.UpperLimit), actual.Select(r => r.UpperBoundary));
}
+ ///
+ /// Gets the based
+ /// on the given .
+ ///
+ /// The to convert.
+ /// A .
+ /// Thrown when
+ /// is not valid.
+ public static FailureMechanismSectionAssemblyCategoryGroup GetFailureMechanismSectionCategoryGroup(EFmSectionCategory category)
+ {
+ switch (category)
+ {
+ case EFmSectionCategory.Iv:
+ return FailureMechanismSectionAssemblyCategoryGroup.Iv;
+ case EFmSectionCategory.IIv:
+ return FailureMechanismSectionAssemblyCategoryGroup.IIv;
+ case EFmSectionCategory.IIIv:
+ return FailureMechanismSectionAssemblyCategoryGroup.IIIv;
+ case EFmSectionCategory.IVv:
+ return FailureMechanismSectionAssemblyCategoryGroup.IVv;
+ case EFmSectionCategory.Vv:
+ return FailureMechanismSectionAssemblyCategoryGroup.Vv;
+ case EFmSectionCategory.VIv:
+ return FailureMechanismSectionAssemblyCategoryGroup.VIv;
+ case EFmSectionCategory.VIIv:
+ return FailureMechanismSectionAssemblyCategoryGroup.VIIv;
+ case EFmSectionCategory.NotApplicable:
+ return FailureMechanismSectionAssemblyCategoryGroup.NotApplicable;
+ case EFmSectionCategory.Gr:
+ return FailureMechanismSectionAssemblyCategoryGroup.None;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+
private static AssessmentSectionAssemblyCategoryGroup GetAssessmentSectionCategoryGroup(EAssessmentGrade category)
{
switch (category)
@@ -137,32 +172,5 @@
throw new NotSupportedException();
}
}
-
- private static FailureMechanismSectionAssemblyCategoryGroup GetFailureMechanismSectionCategoryGroup(EFmSectionCategory category)
- {
- switch (category)
- {
- case EFmSectionCategory.Iv:
- return FailureMechanismSectionAssemblyCategoryGroup.Iv;
- case EFmSectionCategory.IIv:
- return FailureMechanismSectionAssemblyCategoryGroup.IIv;
- case EFmSectionCategory.IIIv:
- return FailureMechanismSectionAssemblyCategoryGroup.IIIv;
- case EFmSectionCategory.IVv:
- return FailureMechanismSectionAssemblyCategoryGroup.IVv;
- case EFmSectionCategory.Vv:
- return FailureMechanismSectionAssemblyCategoryGroup.Vv;
- case EFmSectionCategory.VIv:
- return FailureMechanismSectionAssemblyCategoryGroup.VIv;
- case EFmSectionCategory.VIIv:
- return FailureMechanismSectionAssemblyCategoryGroup.VIIv;
- case EFmSectionCategory.NotApplicable:
- return FailureMechanismSectionAssemblyCategoryGroup.NotApplicable;
- case EFmSectionCategory.Gr:
- return FailureMechanismSectionAssemblyCategoryGroup.None;
- default:
- throw new NotSupportedException();
- }
- }
}
}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/CombinedFailureMechanismSectionAssemblyAssert.cs
===================================================================
diff -u -ra76570f47dca0e8a8eb8a3792f44c82a55dcc5ac -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/CombinedFailureMechanismSectionAssemblyAssert.cs (.../CombinedFailureMechanismSectionAssemblyAssert.cs) (revision a76570f47dca0e8a8eb8a3792f44c82a55dcc5ac)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/CombinedFailureMechanismSectionAssemblyAssert.cs (.../CombinedFailureMechanismSectionAssemblyAssert.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -19,10 +19,9 @@
// 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 Assembly.Kernel.Model;
-using Assembly.Kernel.Model.FmSectionTypes;
using NUnit.Framework;
using Ringtoets.AssemblyTool.Data;
@@ -40,52 +39,26 @@
/// The actual collection of .
/// Thrown when
/// is not equal to .
- public static void AssertAssembly(AssemblyResult original, CombinedFailureMechanismSectionAssembly[] actual)
+ public static void AssertAssembly(AssemblyResult original, IEnumerable actual)
{
FmSectionWithDirectCategory[] combinedResults = original.CombinedSectionResult.ToArray();
- Assert.AreEqual(combinedResults.Length, actual.Length);
- for (var i = 0; i < actual.Length; i++)
+ Assert.AreEqual(combinedResults.Length, actual.Count());
+ for (var i = 0; i < combinedResults.Length; i++)
{
- Assert.AreEqual(combinedResults[i].SectionStart, actual[i].Section.SectionStart);
- Assert.AreEqual(combinedResults[i].SectionEnd, actual[i].Section.SectionEnd);
- Assert.AreEqual(GetResultGroup(combinedResults[i].Category), actual[i].Section.CategoryGroup);
+ Assert.AreEqual(combinedResults[i].SectionStart, actual.ElementAt(i).Section.SectionStart);
+ Assert.AreEqual(combinedResults[i].SectionEnd, actual.ElementAt(i).Section.SectionEnd);
+ Assert.AreEqual(AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(combinedResults[i].Category), actual.ElementAt(i).Section.CategoryGroup);
FailureMechanismSectionList[] failureMechanismResults = original.ResultPerFailureMechanism.ToArray();
- Assert.AreEqual(failureMechanismResults.Length, actual[i].FailureMechanismResults.Count());
+ Assert.AreEqual(failureMechanismResults.Length, actual.ElementAt(i).FailureMechanismResults.Count());
for (var j = 0; j < failureMechanismResults.Length; j++)
{
- FailureMechanismSectionAssemblyCategoryGroup expectedGroup = GetResultGroup(((FmSectionWithDirectCategory) failureMechanismResults[j].Results[i]).Category);
- Assert.AreEqual(expectedGroup, actual[i].FailureMechanismResults.ElementAt(j));
+ FailureMechanismSectionAssemblyCategoryGroup expectedGroup = AssemblyCategoryAssert.GetFailureMechanismSectionCategoryGroup(
+ ((FmSectionWithDirectCategory) failureMechanismResults[j].Results[i]).Category);
+ Assert.AreEqual(expectedGroup, actual.ElementAt(i).FailureMechanismResults.ElementAt(j));
}
}
}
-
- private static FailureMechanismSectionAssemblyCategoryGroup GetResultGroup(EFmSectionCategory combinedResult)
- {
- switch (combinedResult)
- {
- case EFmSectionCategory.Iv:
- return FailureMechanismSectionAssemblyCategoryGroup.Iv;
- case EFmSectionCategory.IIv:
- return FailureMechanismSectionAssemblyCategoryGroup.IIv;
- case EFmSectionCategory.IIIv:
- return FailureMechanismSectionAssemblyCategoryGroup.IIIv;
- case EFmSectionCategory.IVv:
- return FailureMechanismSectionAssemblyCategoryGroup.IVv;
- case EFmSectionCategory.Vv:
- return FailureMechanismSectionAssemblyCategoryGroup.Vv;
- case EFmSectionCategory.VIv:
- return FailureMechanismSectionAssemblyCategoryGroup.VIv;
- case EFmSectionCategory.VIIv:
- return FailureMechanismSectionAssemblyCategoryGroup.VIIv;
- case EFmSectionCategory.Gr:
- return FailureMechanismSectionAssemblyCategoryGroup.None;
- case EFmSectionCategory.NotApplicable:
- return FailureMechanismSectionAssemblyCategoryGroup.NotApplicable;
- default:
- throw new NotSupportedException();
- }
- }
}
}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/CombinedFailureMechanismSectionsInputAssert.cs
===================================================================
diff -u -rdb2a21e6d5285bfd38f4797c30ed4d7c71b3215e -r57210ddafec2d829c866490aa0bd6cebfc2e3a62
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/CombinedFailureMechanismSectionsInputAssert.cs (.../CombinedFailureMechanismSectionsInputAssert.cs) (revision db2a21e6d5285bfd38f4797c30ed4d7c71b3215e)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/CombinedFailureMechanismSectionsInputAssert.cs (.../CombinedFailureMechanismSectionsInputAssert.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.Linq;
using Assembly.Kernel.Model;
using Assembly.Kernel.Model.FmSectionTypes;
@@ -41,21 +42,21 @@
/// The actual collection of .
/// Thrown when
/// is not equal to .
- public static void AssertCombinedFailureMechanismInput(CombinedAssemblyFailureMechanismSection[][] original, FailureMechanismSectionList[] actual)
+ public static void AssertCombinedFailureMechanismInput(IEnumerable original, IEnumerable actual)
{
- Assert.AreEqual(original.Length, actual.Length);
+ Assert.AreEqual(original.Count(), actual.Count());
- for (var i = 0; i < original.Length; i++)
+ for (var i = 0; i < original.Count(); i++)
{
- CombinedAssemblyFailureMechanismSection[] sections = original[i];
- FailureMechanismSectionList sectionList = actual[i];
- AssertSections(sections.ToArray(), sectionList.Results.ToArray());
+ CombinedAssemblyFailureMechanismSection[] sections = original.ElementAt(i);
+ FailureMechanismSectionList sectionList = actual.ElementAt(i);
+ AssertSections(sections, sectionList.Results);
}
}
- private static void AssertSections(CombinedAssemblyFailureMechanismSection[] originalSections, FmSectionWithCategory[] fmSectionWithCategories)
+ private static void AssertSections(IEnumerable originalSections, IEnumerable fmSectionWithCategories)
{
- Assert.AreEqual(originalSections.Length, fmSectionWithCategories.Length);
+ Assert.AreEqual(originalSections.Count(), fmSectionWithCategories.Count());
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));