Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Calculators/Assembly/FailurePathAssemblyCalculator.cs =================================================================== diff -u -r44417bf66e6c62967bdaa7723a2105ac7de5e206 -rcfe29ef6d89e6af74ca09701d5e471a54e984a86 --- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Calculators/Assembly/FailurePathAssemblyCalculator.cs (.../FailurePathAssemblyCalculator.cs) (revision 44417bf66e6c62967bdaa7723a2105ac7de5e206) +++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Calculators/Assembly/FailurePathAssemblyCalculator.cs (.../FailurePathAssemblyCalculator.cs) (revision cfe29ef6d89e6af74ca09701d5e471a54e984a86) @@ -66,7 +66,7 @@ IFailureMechanismResultAssembler kernel = factory.CreateFailurePathAssemblyKernel(); AssemblyFailureMechanismSectionAssemblyResult[] kernelInput = - sectionAssemblyResults.Select(FailurePathAssemblyCalculatorInputCreator.CreateFailurePathSectionAssemblyResult) + sectionAssemblyResults.Select(FailureMechanismAssemblyCalculatorInputCreator.CreateFailureMechanismSectionAssemblyResult) .ToArray(); FailureMechanismAssemblyResult result = kernel.AssembleFailureMechanismWbi1B1(failurePathN, kernelInput, false); Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/FailureMechanismAssemblyCalculatorInputCreator.cs =================================================================== diff -u --- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/FailureMechanismAssemblyCalculatorInputCreator.cs (revision 0) +++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/FailureMechanismAssemblyCalculatorInputCreator.cs (revision cfe29ef6d89e6af74ca09701d5e471a54e984a86) @@ -0,0 +1,105 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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; +using Assembly.Kernel.Model.Categories; +using Riskeer.AssemblyTool.Data; +using AssemblyFailureMechanismSectionAssemblyResult = Assembly.Kernel.Model.FailureMechanismSections.FailureMechanismSectionAssemblyResult; +using RiskeerFailureMechanismSectionAssemblyResult = Riskeer.AssemblyTool.Data.FailureMechanismSectionAssemblyResult; + +namespace Riskeer.AssemblyTool.KernelWrapper.Creators +{ + /// + /// Creates input instances that can be used in the failure mechanism assembly calculator. + /// + internal static class FailureMechanismAssemblyCalculatorInputCreator + { + /// + /// Creates an based on . + /// + /// The to create the + /// with. + /// An . + /// Thrown when is null. + /// Thrown when + /// is an invalid value. + /// Thrown when + /// is a valid value, but unsupported. + public static AssemblyFailureMechanismSectionAssemblyResult CreateFailureMechanismSectionAssemblyResult(RiskeerFailureMechanismSectionAssemblyResult result) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + return new AssemblyFailureMechanismSectionAssemblyResult(new Probability(result.ProfileProbability), + new Probability(result.SectionProbability), + CreateInterpretationCategory(result.AssemblyGroup)); + } + + /// + /// Converts a into a . + /// + /// The to convert. + /// A based on . + /// Thrown when + /// is an invalid value. + /// Thrown when + /// is a valid value, but unsupported. + private static EInterpretationCategory CreateInterpretationCategory(FailureMechanismSectionAssemblyGroup assemblyGroup) + { + if (!Enum.IsDefined(typeof(FailureMechanismSectionAssemblyGroup), assemblyGroup)) + { + throw new InvalidEnumArgumentException(nameof(assemblyGroup), + (int) assemblyGroup, + typeof(FailureMechanismSectionAssemblyGroup)); + } + + switch (assemblyGroup) + { + case FailureMechanismSectionAssemblyGroup.NotDominant: + return EInterpretationCategory.NotDominant; + case FailureMechanismSectionAssemblyGroup.III: + return EInterpretationCategory.III; + case FailureMechanismSectionAssemblyGroup.II: + return EInterpretationCategory.II; + case FailureMechanismSectionAssemblyGroup.I: + return EInterpretationCategory.I; + case FailureMechanismSectionAssemblyGroup.Zero: + return EInterpretationCategory.Zero; + case FailureMechanismSectionAssemblyGroup.IMin: + return EInterpretationCategory.IMin; + case FailureMechanismSectionAssemblyGroup.IIMin: + return EInterpretationCategory.IIMin; + case FailureMechanismSectionAssemblyGroup.IIIMin: + return EInterpretationCategory.IIIMin; + case FailureMechanismSectionAssemblyGroup.Dominant: + return EInterpretationCategory.Dominant; + case FailureMechanismSectionAssemblyGroup.Gr: + return EInterpretationCategory.Gr; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Fisheye: Tag cfe29ef6d89e6af74ca09701d5e471a54e984a86 refers to a dead (removed) revision in file `Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/FailurePathAssemblyCalculatorInputCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Riskeer.AssemblyTool.KernelWrapper.csproj =================================================================== diff -u -r5622c01c7f65869743cc23c4f884bc32f970fb44 -rcfe29ef6d89e6af74ca09701d5e471a54e984a86 --- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Riskeer.AssemblyTool.KernelWrapper.csproj (.../Riskeer.AssemblyTool.KernelWrapper.csproj) (revision 5622c01c7f65869743cc23c4f884bc32f970fb44) +++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Riskeer.AssemblyTool.KernelWrapper.csproj (.../Riskeer.AssemblyTool.KernelWrapper.csproj) (revision cfe29ef6d89e6af74ca09701d5e471a54e984a86) @@ -7,8 +7,8 @@ ..\..\..\..\lib\Plugins\AssemblyTool\Assembly.Kernel.dll - - + + @@ -25,8 +25,8 @@ True Resources.resx - - + + Index: Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismAssemblyCalculatorInputCreatorTest.cs =================================================================== diff -u --- Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismAssemblyCalculatorInputCreatorTest.cs (revision 0) +++ Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismAssemblyCalculatorInputCreatorTest.cs (revision cfe29ef6d89e6af74ca09701d5e471a54e984a86) @@ -0,0 +1,99 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Categories; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.Data; +using Riskeer.AssemblyTool.KernelWrapper.Creators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil; +using AssemblyFailureMechanismSectionAssemblyResult = Assembly.Kernel.Model.FailureMechanismSections.FailureMechanismSectionAssemblyResult; +using RiskeerFailureMechanismSectionAssemblyResult = Riskeer.AssemblyTool.Data.FailureMechanismSectionAssemblyResult; + +namespace Riskeer.AssemblyTool.KernelWrapper.Test.Creators +{ + [TestFixture] + public class FailureMechanismAssemblyCalculatorInputCreatorTest + { + [Test] + public void CreateFailureMechanismSectionAssemblyResult_ResultNull_ThrowsArgumentNullException() + { + // Call + void Call() => FailureMechanismAssemblyCalculatorInputCreator.CreateFailureMechanismSectionAssemblyResult(null); + + // Assert + Assert.That(Call, Throws.TypeOf() + .With.Property(nameof(ArgumentNullException.ParamName)) + .EqualTo("result")); + } + + [Test] + [TestCase(FailureMechanismSectionAssemblyGroup.NotDominant, EInterpretationCategory.NotDominant)] + [TestCase(FailureMechanismSectionAssemblyGroup.III, EInterpretationCategory.III)] + [TestCase(FailureMechanismSectionAssemblyGroup.II, EInterpretationCategory.II)] + [TestCase(FailureMechanismSectionAssemblyGroup.I, EInterpretationCategory.I)] + [TestCase(FailureMechanismSectionAssemblyGroup.Zero, EInterpretationCategory.Zero)] + [TestCase(FailureMechanismSectionAssemblyGroup.IMin, EInterpretationCategory.IMin)] + [TestCase(FailureMechanismSectionAssemblyGroup.IIMin, EInterpretationCategory.IIMin)] + [TestCase(FailureMechanismSectionAssemblyGroup.IIIMin, EInterpretationCategory.IIIMin)] + [TestCase(FailureMechanismSectionAssemblyGroup.Dominant, EInterpretationCategory.Dominant)] + [TestCase(FailureMechanismSectionAssemblyGroup.Gr, EInterpretationCategory.Gr)] + public void CreateFailureMechanismSectionAssemblyResult_WithValidResult_ReturnsExpectedFailureMechanismSectionAssemblyResult( + FailureMechanismSectionAssemblyGroup assemblyGroup, EInterpretationCategory expectedCategory) + { + // Setup + var random = new Random(21); + double profileProbability = random.NextDouble(); + double sectionProbability = profileProbability + 0.001; + + var result = new RiskeerFailureMechanismSectionAssemblyResult(profileProbability, sectionProbability, + random.NextDouble(), + assemblyGroup); + // Call + AssemblyFailureMechanismSectionAssemblyResult createdResult = FailureMechanismAssemblyCalculatorInputCreator.CreateFailureMechanismSectionAssemblyResult(result); + + // Assert + ProbabilityAssert.AreEqual(profileProbability, createdResult.ProbabilityProfile); + ProbabilityAssert.AreEqual(sectionProbability, createdResult.ProbabilitySection); + Assert.AreEqual(expectedCategory, createdResult.InterpretationCategory); + } + + [Test] + public void CreateFailureMechanismSectionAssemblyResult_InvalidAssemblyGroup_ThrowsInvalidEnumArgumentException() + { + // Setup + var random = new Random(21); + double probability = random.NextDouble(); + var result = new RiskeerFailureMechanismSectionAssemblyResult(probability, probability, + random.NextDouble(), + (FailureMechanismSectionAssemblyGroup) 99); + + // Call + void Call() => FailureMechanismAssemblyCalculatorInputCreator.CreateFailureMechanismSectionAssemblyResult(result); + + // Assert + var expectedMessage = $"The value of argument 'assemblyGroup' (99) is invalid for Enum type '{nameof(FailureMechanismSectionAssemblyGroup)}'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); + } + } +} \ No newline at end of file Fisheye: Tag cfe29ef6d89e6af74ca09701d5e471a54e984a86 refers to a dead (removed) revision in file `Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/FailurePathAssemblyCalculatorInputCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Riskeer.AssemblyTool.KernelWrapper.Test.csproj =================================================================== diff -u -rfa6b41745f75625989787406e5bb0001e6a71a2e -rcfe29ef6d89e6af74ca09701d5e471a54e984a86 --- Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Riskeer.AssemblyTool.KernelWrapper.Test.csproj (.../Riskeer.AssemblyTool.KernelWrapper.Test.csproj) (revision fa6b41745f75625989787406e5bb0001e6a71a2e) +++ Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Riskeer.AssemblyTool.KernelWrapper.Test.csproj (.../Riskeer.AssemblyTool.KernelWrapper.Test.csproj) (revision cfe29ef6d89e6af74ca09701d5e471a54e984a86) @@ -7,20 +7,20 @@ ..\..\..\..\lib\Plugins\AssemblyTool\Assembly.Kernel.dll - - + + Copying.licenseheader - - - - - + + + + +