Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableAssemblyCreator.cs =================================================================== diff -u -r533c09fa374c801775800668d9046f9470db2f07 -r66867c059a3d1c4846828871cdf6d354b2b608a6 --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableAssemblyCreator.cs (.../SerializableAssemblyCreator.cs) (revision 533c09fa374c801775800668d9046f9470db2f07) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableAssemblyCreator.cs (.../SerializableAssemblyCreator.cs) (revision 66867c059a3d1c4846828871cdf6d354b2b608a6) @@ -66,8 +66,8 @@ serializableAssessmentProcess, SerializableTotalAssemblyResultCreator.Create(idGenerator, serializableAssessmentProcess, - new SerializableFailureMechanismAssemblyResult(), - new SerializableFailureMechanismAssemblyResult(), + SerializableFailureMechanismResultCreator.Create(assessmentSection.FailureMechanismAssemblyWithProbability), + SerializableFailureMechanismResultCreator.Create(assessmentSection.FailureMechanismAssemblyWithoutProbability), new SerializableAssessmentSectionAssemblyResult()), Enumerable.Empty(), Enumerable.Empty(), Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismResultCreator.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismResultCreator.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismResultCreator.cs (revision 66867c059a3d1c4846828871cdf6d354b2b608a6) @@ -0,0 +1,74 @@ +// 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 Ringtoets.AssemblyTool.IO.Model.DataTypes; +using Ringtoets.Integration.IO.Assembly; + +namespace Ringtoets.Integration.IO.Creators +{ + /// + /// Creator to create instances of . + /// + public static class SerializableFailureMechanismResultCreator + { + /// + /// Creates a + /// based on a . + /// + /// The + /// to create a for. + /// A . + /// Thrown when + /// is null. + public static SerializableFailureMechanismAssemblyResult Create(ExportableFailureMechanismAssemblyResult result) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + return new SerializableFailureMechanismAssemblyResult(SerializableAssemblyMethodCreator.Create(result.AssemblyMethod), + SerializableFailureMechanismCategoryGroupCreator.Create(result.AssemblyCategory)); + } + + /// + /// Creates a + /// based on a . + /// + /// The + /// to create a for. + /// A . + /// Thrown when + /// is null. + public static SerializableFailureMechanismAssemblyResult Create(ExportableFailureMechanismAssemblyResultWithProbability result) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + return new SerializableFailureMechanismAssemblyResult(SerializableAssemblyMethodCreator.Create(result.AssemblyMethod), + SerializableFailureMechanismCategoryGroupCreator.Create(result.AssemblyCategory), + result.Probability); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj =================================================================== diff -u -r2e1a9648c3c88c68c7cdf3826e18c3cfedc11af0 -r66867c059a3d1c4846828871cdf6d354b2b608a6 --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 2e1a9648c3c88c68c7cdf3826e18c3cfedc11af0) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 66867c059a3d1c4846828871cdf6d354b2b608a6) @@ -40,6 +40,7 @@ + Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssemblyCreatorTest.cs =================================================================== diff -u -r533c09fa374c801775800668d9046f9470db2f07 -r66867c059a3d1c4846828871cdf6d354b2b608a6 --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssemblyCreatorTest.cs (.../SerializableAssemblyCreatorTest.cs) (revision 533c09fa374c801775800668d9046f9470db2f07) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssemblyCreatorTest.cs (.../SerializableAssemblyCreatorTest.cs) (revision 66867c059a3d1c4846828871cdf6d354b2b608a6) @@ -25,6 +25,7 @@ using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.AssemblyTool.IO.Model; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; using Ringtoets.AssemblyTool.IO.Model.Gml; using Ringtoets.AssemblyTool.IO.Model.Helpers; using Ringtoets.Integration.IO.Assembly; @@ -155,6 +156,21 @@ { Assert.AreEqual(expectedId, serializableTotalAssembly.Id); Assert.AreEqual(expectedAssessmentProcess.Id, serializableTotalAssembly.AssessmentProcessId); + + SerializableFailureMechanismAssemblyResult serializableAssemblyResultWithoutProbability = serializableTotalAssembly.AssemblyResultWithoutProbability; + Assert.AreEqual(SerializableFailureMechanismCategoryGroupCreator.Create(expectedFailureMechanismAssemblyResultWithoutProbability.AssemblyCategory), + serializableAssemblyResultWithoutProbability.CategoryGroup); + Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedFailureMechanismAssemblyResultWithoutProbability.AssemblyMethod), + serializableAssemblyResultWithoutProbability.AssemblyMethod); + Assert.IsNull(serializableAssemblyResultWithoutProbability.Probability); + + SerializableFailureMechanismAssemblyResult serializableAssemblyResultWithProbability = serializableTotalAssembly.AssemblyResultWithProbability; + Assert.AreEqual(SerializableFailureMechanismCategoryGroupCreator.Create(expectedFailureMechanismAssemblyResultWithProbability.AssemblyCategory), + serializableAssemblyResultWithProbability.CategoryGroup); + Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedFailureMechanismAssemblyResultWithProbability.AssemblyMethod), + serializableAssemblyResultWithProbability.AssemblyMethod); + Assert.AreEqual(expectedFailureMechanismAssemblyResultWithProbability.Probability, + serializableAssemblyResultWithProbability.Probability); } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismResultCreatorTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismResultCreatorTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismResultCreatorTest.cs (revision 66867c059a3d1c4846828871cdf6d354b2b608a6) @@ -0,0 +1,95 @@ +// 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; +using Ringtoets.Integration.IO.Assembly; +using Ringtoets.Integration.IO.Creators; + +namespace Ringtoets.Integration.IO.Test.Creators +{ + [TestFixture] + public class SerializableFailureMechanismResultCreatorTest + { + [Test] + public void CreateWithFailureMechanismAssemblyResult_ResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => SerializableFailureMechanismResultCreator.Create(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("result", exception.ParamName); + } + + [Test] + public void Create_WithFailureMechanismAssemblyResult_ReturnsSerializableFailureMechanismAssemblyResult() + { + // Setup + var random = new Random(21); + var result = new ExportableFailureMechanismAssemblyResult(random.NextEnumValue(), + random.NextEnumValue()); + + // Call + SerializableFailureMechanismAssemblyResult serializableAssemblyResult = SerializableFailureMechanismResultCreator.Create(result); + + // Assert + Assert.AreEqual(SerializableFailureMechanismCategoryGroupCreator.Create(result.AssemblyCategory), serializableAssemblyResult.CategoryGroup); + Assert.AreEqual(SerializableAssemblyMethodCreator.Create(result.AssemblyMethod), serializableAssemblyResult.AssemblyMethod); + Assert.IsNull(serializableAssemblyResult.Probability); + } + + [Test] + public void CreateWithFailureMechanismAssemblyResultWithProbability_ResultNull_ThrowsArgumentNullException() + { + // Setup + var result = (ExportableFailureMechanismAssemblyResultWithProbability) null; + + // Call + TestDelegate call = () => SerializableFailureMechanismResultCreator.Create(result); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("result", exception.ParamName); + } + + [Test] + public void Create_WithFailureMechanismAssemblyResultWithProbability_ReturnsSerializableFailureMechanismAssemblyResult() + { + // Setup + var random = new Random(21); + var result = new ExportableFailureMechanismAssemblyResultWithProbability(random.NextEnumValue(), + random.NextEnumValue(), + random.NextDouble()); + + // Call + SerializableFailureMechanismAssemblyResult serializableAssemblyResult = SerializableFailureMechanismResultCreator.Create(result); + + // Assert + Assert.AreEqual(SerializableFailureMechanismCategoryGroupCreator.Create(result.AssemblyCategory), serializableAssemblyResult.CategoryGroup); + Assert.AreEqual(SerializableAssemblyMethodCreator.Create(result.AssemblyMethod), serializableAssemblyResult.AssemblyMethod); + Assert.AreEqual(result.Probability, serializableAssemblyResult.Probability); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj =================================================================== diff -u -r2e1a9648c3c88c68c7cdf3826e18c3cfedc11af0 -r66867c059a3d1c4846828871cdf6d354b2b608a6 --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 2e1a9648c3c88c68c7cdf3826e18c3cfedc11af0) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 66867c059a3d1c4846828871cdf6d354b2b608a6) @@ -42,6 +42,7 @@ +