Index: Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.TestUtil/ExportableFailureMechanismSectionAssemblyResultTestHelper.cs =================================================================== diff -u -rebec6b457e0542ba44b77d1c2471d8966537955d -r67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 --- Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.TestUtil/ExportableFailureMechanismSectionAssemblyResultTestHelper.cs (.../ExportableFailureMechanismSectionAssemblyResultTestHelper.cs) (revision ebec6b457e0542ba44b77d1c2471d8966537955d) +++ Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.TestUtil/ExportableFailureMechanismSectionAssemblyResultTestHelper.cs (.../ExportableFailureMechanismSectionAssemblyResultTestHelper.cs) (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9) @@ -85,9 +85,9 @@ FailureMechanismSectionAssemblyResult expectedAssemblyResult = expectedAssemblyResultWrapper.AssemblyResult; Assert.AreEqual(expectedAssemblyResult.FailureMechanismSectionAssemblyGroup, actualExportableAssemblyResult.AssemblyGroup); Assert.AreEqual(expectedAssemblyResult.SectionProbability, actualExportableAssemblyResult.Probability); - Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedAssemblyResultWrapper.AssemblyGroupMethod), + Assert.AreEqual(ExportableAssemblyMethodConverter.ConvertTo(expectedAssemblyResultWrapper.AssemblyGroupMethod), actualExportableAssemblyResult.AssemblyGroupAssemblyMethod); - Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedAssemblyResultWrapper.ProbabilityMethod), + Assert.AreEqual(ExportableAssemblyMethodConverter.ConvertTo(expectedAssemblyResultWrapper.ProbabilityMethod), actualExportableAssemblyResult.ProbabilityAssemblyMethod); } } Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssemblyMethodConverter.cs =================================================================== diff -u --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssemblyMethodConverter.cs (revision 0) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssemblyMethodConverter.cs (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9) @@ -0,0 +1,86 @@ +// Copyright (C) Stichting Deltares 2022. 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 Riskeer.AssemblyTool.Data; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.Integration.IO.Factories +{ + /// + /// Converter for converting into . + /// + public static class ExportableAssemblyMethodConverter + { + /// + /// Converts an into an . + /// + /// The + /// to convert into an . + /// An . + /// Thrown when + /// is an invalid value. + /// Thrown when + /// is a valid value, but unsupported. + public static ExportableAssemblyMethod ConvertTo(AssemblyMethod assemblyMethod) + { + if (!Enum.IsDefined(typeof(AssemblyMethod), assemblyMethod)) + { + throw new InvalidEnumArgumentException(nameof(assemblyMethod), + (int) assemblyMethod, + typeof(AssemblyMethod)); + } + + switch (assemblyMethod) + { + case AssemblyMethod.BOI0A1: + return ExportableAssemblyMethod.BOI0A1; + case AssemblyMethod.BOI0A2: + return ExportableAssemblyMethod.BOI0A2; + case AssemblyMethod.BOI0B1: + return ExportableAssemblyMethod.BOI0B1; + case AssemblyMethod.BOI0C1: + return ExportableAssemblyMethod.BOI0C1; + case AssemblyMethod.BOI0C2: + return ExportableAssemblyMethod.BOI0C2; + case AssemblyMethod.BOI1A1: + return ExportableAssemblyMethod.BOI1A1; + case AssemblyMethod.BOI1A2: + return ExportableAssemblyMethod.BOI1A2; + case AssemblyMethod.Manual: + return ExportableAssemblyMethod.Manual; + case AssemblyMethod.BOI2A1: + return ExportableAssemblyMethod.BOI2A1; + case AssemblyMethod.BOI2B1: + return ExportableAssemblyMethod.BOI2B1; + case AssemblyMethod.BOI3A1: + return ExportableAssemblyMethod.BOI3A1; + case AssemblyMethod.BOI3B1: + return ExportableAssemblyMethod.BOI3B1; + case AssemblyMethod.BOI3C1: + return ExportableAssemblyMethod.BOI3C1; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Fisheye: Tag 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssemblyMethodFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs =================================================================== diff -u -rb7414e083e86a5b6e91294ed7c38477ed119b042 -r67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision b7414e083e86a5b6e91294ed7c38477ed119b042) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9) @@ -107,8 +107,8 @@ return new ExportableAssessmentSectionAssemblyResult( idGenerator.GetNewId(Resources.ExportableTotalAssemblyResult_IdPrefix), ConvertAssemblyGroup(assemblyResult.AssemblyGroup), assemblyResult.Probability, - ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.AssemblyGroupMethod), - ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.ProbabilityMethod)); + ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.AssemblyGroupMethod), + ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.ProbabilityMethod)); } /// Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs =================================================================== diff -u -r8207feaf9b12bc87b924cde143f7af6a8eac0f0b -r67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs (.../ExportableCombinedSectionAssemblyFactory.cs) (revision 8207feaf9b12bc87b924cde143f7af6a8eac0f0b) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs (.../ExportableCombinedSectionAssemblyFactory.cs) (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9) @@ -77,11 +77,11 @@ "id", FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry( assessmentSection.ReferenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd), assemblyResult.SectionStart, assemblyResult.SectionEnd, - ExportableAssemblyMethodFactory.Create(assemblyResult.CommonSectionAssemblyMethod)); + ExportableAssemblyMethodConverter.ConvertTo(assemblyResult.CommonSectionAssemblyMethod)); var exportableSectionResult = new ExportableCombinedSectionAssembly( "id", exportableSection, assemblyResult.TotalResult, - ExportableAssemblyMethodFactory.Create(assemblyResult.CombinedSectionResultAssemblyMethod), + ExportableAssemblyMethodConverter.ConvertTo(assemblyResult.CombinedSectionResultAssemblyMethod), CreateFailureMechanismCombinedSectionAssemblyResults(assemblyResult, assessmentSection)); sectionResults.Add(exportableSectionResult); @@ -143,7 +143,7 @@ FailureMechanismSectionAssemblyGroup sectionAssemblyGroup, AssemblyMethod assemblyMethod) { return new ExportableFailureMechanismCombinedSectionAssemblyResult( - sectionAssemblyGroup, ExportableAssemblyMethodFactory.Create(assemblyMethod), + sectionAssemblyGroup, ExportableAssemblyMethodConverter.ConvertTo(assemblyMethod), new ExportableFailureMechanismSectionAssemblyResult( "id", new ExportableFailureMechanismSection("id", Array.Empty(), double.NaN, double.NaN), double.NaN, FailureMechanismSectionAssemblyGroup.Zero, ExportableAssemblyMethod.Manual, ExportableAssemblyMethod.Manual)); Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs =================================================================== diff -u -rebec6b457e0542ba44b77d1c2471d8966537955d -r67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs (.../ExportableFailureMechanismFactory.cs) (revision ebec6b457e0542ba44b77d1c2471d8966537955d) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs (.../ExportableFailureMechanismFactory.cs) (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9) @@ -99,7 +99,7 @@ return new ExportableGenericFailureMechanism(idGenerator.GetNewId(Resources.ExportableFailureMechanism_IdPrefix), new ExportableFailureMechanismAssemblyResult( assemblyResultWrapper.AssemblyResult, - ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.AssemblyMethod)), + ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.AssemblyMethod)), CreateExportableFailureMechanismSectionResults( idGenerator, registry, failureMechanism, assessmentSection, assembleFailureMechanismSectionFunc), failureMechanism.Code); @@ -161,7 +161,7 @@ return new ExportableSpecificFailureMechanism(idGenerator.GetNewId(Resources.ExportableFailureMechanism_IdPrefix), new ExportableFailureMechanismAssemblyResult( assemblyResultWrapper.AssemblyResult, - ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.AssemblyMethod)), + ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.AssemblyMethod)), CreateExportableFailureMechanismSectionResults( idGenerator, registry, failureMechanism, assessmentSection, assembleFailureMechanismSectionFunc), failureMechanism.Name); Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionAssemblyResultFactory.cs =================================================================== diff -u -rebec6b457e0542ba44b77d1c2471d8966537955d -r67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionAssemblyResultFactory.cs (.../ExportableFailureMechanismSectionAssemblyResultFactory.cs) (revision ebec6b457e0542ba44b77d1c2471d8966537955d) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionAssemblyResultFactory.cs (.../ExportableFailureMechanismSectionAssemblyResultFactory.cs) (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9) @@ -103,8 +103,8 @@ idGenerator.GetNewId(Resources.ExportableFailureMechanismSectionAssemblyResult_IdPrefix), registry.Get(sectionResult.Section), assemblyResult.SectionProbability, assemblyResult.FailureMechanismSectionAssemblyGroup, - ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.AssemblyGroupMethod), - ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.ProbabilityMethod)); + ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.AssemblyGroupMethod), + ExportableAssemblyMethodConverter.ConvertTo(assemblyResultWrapper.ProbabilityMethod)); } } } \ No newline at end of file Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssemblyMethodConverterTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssemblyMethodConverterTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssemblyMethodConverterTest.cs (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9) @@ -0,0 +1,71 @@ +// Copyright (C) Stichting Deltares 2022. 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.ComponentModel; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.Data; +using Riskeer.AssemblyTool.IO.Model.Enums; +using Riskeer.Integration.IO.Factories; + +namespace Riskeer.Integration.IO.Test.Factories +{ + [TestFixture] + public class ExportableAssemblyMethodConverterTest + { + [Test] + public void ConvertTo_InvalidAssemblyMethod_ThrowInvalidEnumArgumentException() + { + // Setup + const AssemblyMethod assemblyMethod = (AssemblyMethod) 999; + + // ExportableAssemblyMethodFactory + void Call() => ExportableAssemblyMethodConverter.ConvertTo(assemblyMethod); + + // Assert + var message = $"The value of argument 'assemblyMethod' ({assemblyMethod}) is invalid for Enum type '{nameof(AssemblyMethod)}'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, message); + } + + [Test] + [TestCase(AssemblyMethod.BOI0A1, ExportableAssemblyMethod.BOI0A1)] + [TestCase(AssemblyMethod.BOI0A2, ExportableAssemblyMethod.BOI0A2)] + [TestCase(AssemblyMethod.BOI0B1, ExportableAssemblyMethod.BOI0B1)] + [TestCase(AssemblyMethod.BOI0C1, ExportableAssemblyMethod.BOI0C1)] + [TestCase(AssemblyMethod.BOI1A1, ExportableAssemblyMethod.BOI1A1)] + [TestCase(AssemblyMethod.BOI1A2, ExportableAssemblyMethod.BOI1A2)] + [TestCase(AssemblyMethod.Manual, ExportableAssemblyMethod.Manual)] + [TestCase(AssemblyMethod.BOI2A1, ExportableAssemblyMethod.BOI2A1)] + [TestCase(AssemblyMethod.BOI2B1, ExportableAssemblyMethod.BOI2B1)] + [TestCase(AssemblyMethod.BOI3A1, ExportableAssemblyMethod.BOI3A1)] + [TestCase(AssemblyMethod.BOI3B1, ExportableAssemblyMethod.BOI3B1)] + [TestCase(AssemblyMethod.BOI3C1, ExportableAssemblyMethod.BOI3C1)] + public void ConvertTo_WithAssemblyMethod_ReturnsExpectedValues(AssemblyMethod assemblyMethod, + ExportableAssemblyMethod expectedAssemblyMethod) + { + // Call + ExportableAssemblyMethod exportableAssemblyMethod = ExportableAssemblyMethodConverter.ConvertTo(assemblyMethod); + + // Assert + Assert.AreEqual(expectedAssemblyMethod, exportableAssemblyMethod); + } + } +} \ No newline at end of file Fisheye: Tag 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssemblyMethodFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableCombinedSectionAssemblyFactoryTest.cs =================================================================== diff -u -r8207feaf9b12bc87b924cde143f7af6a8eac0f0b -r67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableCombinedSectionAssemblyFactoryTest.cs (.../ExportableCombinedSectionAssemblyFactoryTest.cs) (revision 8207feaf9b12bc87b924cde143f7af6a8eac0f0b) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableCombinedSectionAssemblyFactoryTest.cs (.../ExportableCombinedSectionAssemblyFactoryTest.cs) (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9) @@ -201,7 +201,7 @@ Assert.AreEqual(expectedSection.SectionStart, actualSection.StartDistance); Assert.AreEqual(expectedSection.SectionEnd, actualSection.EndDistance); CollectionAssert.AreEqual(expectedGeometry, actualSection.Geometry); - Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedSection.CommonSectionAssemblyMethod), actualSection.AssemblyMethod); + Assert.AreEqual(ExportableAssemblyMethodConverter.ConvertTo(expectedSection.CommonSectionAssemblyMethod), actualSection.AssemblyMethod); } private static void AssertExportableCombinedFailureMechanismSectionResult(CombinedFailureMechanismSectionAssemblyResult expectedSection, @@ -211,7 +211,7 @@ { Assert.AreSame(actualSection, actualSectionResult.Section); Assert.AreEqual(expectedSection.TotalResult, actualSectionResult.AssemblyGroup); - Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedSection.CombinedSectionResultAssemblyMethod), actualSectionResult.AssemblyGroupAssemblyMethod); + Assert.AreEqual(ExportableAssemblyMethodConverter.ConvertTo(expectedSection.CombinedSectionResultAssemblyMethod), actualSectionResult.AssemblyGroupAssemblyMethod); IEnumerable failureMechanismCombinedSectionResults = actualSectionResult.FailureMechanismResults; @@ -222,7 +222,7 @@ } Assert.AreEqual(17, failureMechanismCombinedSectionResults.Count()); - Assert.IsTrue(failureMechanismCombinedSectionResults.All(result => result.AssemblyMethod == ExportableAssemblyMethodFactory.Create( + Assert.IsTrue(failureMechanismCombinedSectionResults.All(result => result.AssemblyMethod == ExportableAssemblyMethodConverter.ConvertTo( expectedSection.FailureMechanismResultsAssemblyMethod))); AssertSubSection(expectedSection.Piping, "STPH", ExportableFailureMechanismType.Generic, Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismFactoryTest.cs =================================================================== diff -u -rebec6b457e0542ba44b77d1c2471d8966537955d -r67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismFactoryTest.cs (.../ExportableFailureMechanismFactoryTest.cs) (revision ebec6b457e0542ba44b77d1c2471d8966537955d) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismFactoryTest.cs (.../ExportableFailureMechanismFactoryTest.cs) (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9) @@ -172,7 +172,7 @@ ExportableFailureMechanismAssemblyResult exportableFailureMechanismAssembly = exportableFailureMechanism.FailureMechanismAssembly; Assert.AreEqual(probability, exportableFailureMechanismAssembly.Probability); - Assert.AreEqual(ExportableAssemblyMethodFactory.Create(assemblyMethod), exportableFailureMechanismAssembly.AssemblyMethod); + Assert.AreEqual(ExportableAssemblyMethodConverter.ConvertTo(assemblyMethod), exportableFailureMechanismAssembly.AssemblyMethod); IEnumerable exportableFailureMechanismSections = exportableFailureMechanism.SectionAssemblyResults .Select(sar => sar.FailureMechanismSection); @@ -313,7 +313,7 @@ ExportableFailureMechanismAssemblyResult exportableFailureMechanismAssembly = exportableFailureMechanism.FailureMechanismAssembly; Assert.AreEqual(probability, exportableFailureMechanismAssembly.Probability); - Assert.AreEqual(ExportableAssemblyMethodFactory.Create(assemblyMethod), exportableFailureMechanismAssembly.AssemblyMethod); + Assert.AreEqual(ExportableAssemblyMethodConverter.ConvertTo(assemblyMethod), exportableFailureMechanismAssembly.AssemblyMethod); IEnumerable exportableFailureMechanismSections = exportableFailureMechanism.SectionAssemblyResults .Select(sar => sar.FailureMechanismSection);