Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableAssemblyCreator.cs =================================================================== diff -u -r5ec6a3a075e322e2ca2eddfaf5b3a3f3a2413522 -r533c09fa374c801775800668d9046f9470db2f07 --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableAssemblyCreator.cs (.../SerializableAssemblyCreator.cs) (revision 5ec6a3a075e322e2ca2eddfaf5b3a3f3a2413522) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableAssemblyCreator.cs (.../SerializableAssemblyCreator.cs) (revision 533c09fa374c801775800668d9046f9470db2f07) @@ -24,6 +24,7 @@ using System.Linq; using Core.Common.Base.Geometry; using Ringtoets.AssemblyTool.IO.Model; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; using Ringtoets.Integration.IO.Assembly; using Ringtoets.Integration.IO.Helpers; @@ -56,12 +57,18 @@ SerializableAssessmentSection serializableAssessmentSection = SerializableAssessmentSectionCreator.Create(idGenerator, assessmentSection.Name, assessmentSection.Geometry); + SerializableAssessmentProcess serializableAssessmentProcess = SerializableAssessmentProcessCreator.Create(idGenerator, serializableAssessmentSection); + return new SerializableAssembly(serializableAssemblyId, GetLowerCorner(assessmentSection.Geometry), GetUpperCorner(assessmentSection.Geometry), serializableAssessmentSection, - SerializableAssessmentProcessCreator.Create(idGenerator, serializableAssessmentSection), - new SerializableTotalAssemblyResult(), + serializableAssessmentProcess, + SerializableTotalAssemblyResultCreator.Create(idGenerator, + serializableAssessmentProcess, + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableAssessmentSectionAssemblyResult()), Enumerable.Empty(), Enumerable.Empty(), Enumerable.Empty(), Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableTotalAssemblyResultCreator.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableTotalAssemblyResultCreator.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableTotalAssemblyResultCreator.cs (revision 533c09fa374c801775800668d9046f9470db2f07) @@ -0,0 +1,63 @@ +// 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; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; +using Ringtoets.Integration.IO.Helpers; + +namespace Ringtoets.Integration.IO.Creators +{ + /// + /// Creator to create instances of + /// + public static class SerializableTotalAssemblyResultCreator + { + /// + /// Creates an instance of + /// based on its input parameters + /// + /// The generator to generate an id for . + /// The assessment process this result belongs to. + /// The assembly result for failure mechanisms with probability. + /// The assembly result for failure mechanisms without probability. + /// The assembly result for the assessment section. + /// A . + /// Thrown when any parameter is null. + public static SerializableTotalAssemblyResult Create(UniqueIdentifierGenerator idGenerator, + SerializableAssessmentProcess assessmentProcess, + SerializableFailureMechanismAssemblyResult failureMechanismAssemblyResultWithProbability, + SerializableFailureMechanismAssemblyResult failureMechanismAssemblyResultWithoutProbability, + SerializableAssessmentSectionAssemblyResult assessmentSectionAssemblyResult) + { + if (idGenerator == null) + { + throw new ArgumentNullException(nameof(idGenerator)); + } + + return new SerializableTotalAssemblyResult(idGenerator.GetNewId(), + assessmentProcess, + failureMechanismAssemblyResultWithoutProbability, + failureMechanismAssemblyResultWithProbability, + assessmentSectionAssemblyResult); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj =================================================================== diff -u -r5ec6a3a075e322e2ca2eddfaf5b3a3f3a2413522 -r533c09fa374c801775800668d9046f9470db2f07 --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 5ec6a3a075e322e2ca2eddfaf5b3a3f3a2413522) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 533c09fa374c801775800668d9046f9470db2f07) @@ -37,6 +37,7 @@ + Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssemblyCreatorTest.cs =================================================================== diff -u -r5ec6a3a075e322e2ca2eddfaf5b3a3f3a2413522 -r533c09fa374c801775800668d9046f9470db2f07 --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssemblyCreatorTest.cs (.../SerializableAssemblyCreatorTest.cs) (revision 5ec6a3a075e322e2ca2eddfaf5b3a3f3a2413522) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssemblyCreatorTest.cs (.../SerializableAssemblyCreatorTest.cs) (revision 533c09fa374c801775800668d9046f9470db2f07) @@ -85,7 +85,14 @@ var serializableAssessmentSection = (SerializableAssessmentSection) serializableAssembly.FeatureMembers[0]; AssertSerializableAssessmentSection("1", assessmentSectionName, geometry, serializableAssessmentSection); - AssertSerializableAssessmentProcess("2", serializableAssessmentSection, (SerializableAssessmentProcess) serializableAssembly.FeatureMembers[1]); + var serializableAssessmentProcess = (SerializableAssessmentProcess) serializableAssembly.FeatureMembers[1]; + AssertSerializableAssessmentProcess("2", serializableAssessmentSection, serializableAssessmentProcess); + AssertSerializableTotalAssemblyResult("3", + failureMechanismAssemblyResultWithoutProbability, + failureMechanismAssemblyResultWithProbability, + assessmentSectionAssembly, + serializableAssessmentProcess, + (SerializableTotalAssemblyResult) serializableAssembly.FeatureMembers[2]); } private static IEnumerable CreateGeometry() @@ -132,11 +139,22 @@ } private static void AssertSerializableAssessmentProcess(string expectedId, - SerializableAssessmentSection expectedSerializableAssessmentSection, + SerializableAssessmentSection expectedAssessmentSection, SerializableAssessmentProcess serializableAssessmentProcess) { Assert.AreEqual(expectedId, serializableAssessmentProcess.Id); - Assert.AreEqual(expectedSerializableAssessmentSection.Id, serializableAssessmentProcess.AssessmentSectionId); + Assert.AreEqual(expectedAssessmentSection.Id, serializableAssessmentProcess.AssessmentSectionId); } + + private static void AssertSerializableTotalAssemblyResult(string expectedId, + ExportableFailureMechanismAssemblyResult expectedFailureMechanismAssemblyResultWithoutProbability, + ExportableFailureMechanismAssemblyResultWithProbability expectedFailureMechanismAssemblyResultWithProbability, + ExportableAssessmentSectionAssemblyResult expectedAssessmentSectionAssemblyResult, + SerializableAssessmentProcess expectedAssessmentProcess, + SerializableTotalAssemblyResult serializableTotalAssembly) + { + Assert.AreEqual(expectedId, serializableTotalAssembly.Id); + Assert.AreEqual(expectedAssessmentProcess.Id, serializableTotalAssembly.AssessmentProcessId); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableTotalAssemblyResultCreatorTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableTotalAssemblyResultCreatorTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableTotalAssemblyResultCreatorTest.cs (revision 533c09fa374c801775800668d9046f9470db2f07) @@ -0,0 +1,137 @@ +// 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 NUnit.Framework; +using Ringtoets.AssemblyTool.IO.Model; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; +using Ringtoets.Integration.IO.Creators; +using Ringtoets.Integration.IO.Helpers; + +namespace Ringtoets.Integration.IO.Test.Creators +{ + [TestFixture] + public class SerializableTotalAssemblyResultCreatorTest + { + [Test] + public void Create_IdGeneratorNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => SerializableTotalAssemblyResultCreator.Create(null, + new SerializableAssessmentProcess(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableAssessmentSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("idGenerator", exception.ParamName); + } + + [Test] + public void Create_AssessmentProcessNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => SerializableTotalAssemblyResultCreator.Create(new UniqueIdentifierGenerator(), + null, + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableAssessmentSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentProcess", exception.ParamName); + } + + [Test] + public void Create_FailureMechanismAssemblyResultWithProbabilityNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => SerializableTotalAssemblyResultCreator.Create(new UniqueIdentifierGenerator(), + new SerializableAssessmentProcess(), + null, + new SerializableFailureMechanismAssemblyResult(), + new SerializableAssessmentSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assemblyResultWithProbability", exception.ParamName); + } + + [Test] + public void Create_FailureMechanismAssemblyResultWithoutProbabilityNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => SerializableTotalAssemblyResultCreator.Create(new UniqueIdentifierGenerator(), + new SerializableAssessmentProcess(), + new SerializableFailureMechanismAssemblyResult(), + null, + new SerializableAssessmentSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assemblyResultWithoutProbability", exception.ParamName); + } + + [Test] + public void Create_AssessmentSectionAssemblyResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => SerializableTotalAssemblyResultCreator.Create(new UniqueIdentifierGenerator(), + new SerializableAssessmentProcess(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSectionAssemblyResult", exception.ParamName); + } + + [Test] + public void Create_WithValidArguments_ReturnsSerializableTotalAssemblyResult() + { + // Setup + var idGenerator = new UniqueIdentifierGenerator(); + + const string assessmentProcessId = "serializable assessment process id"; + var serializableAssessmentProcess = new SerializableAssessmentProcess(assessmentProcessId, new SerializableAssessmentSection()); + var failureMechanismAssemblyResultWithProbability = new SerializableFailureMechanismAssemblyResult(); + var failureMechanismAssemblyResultWithoutProbability = new SerializableFailureMechanismAssemblyResult(); + var assessmentSectionAssemblyResult = new SerializableAssessmentSectionAssemblyResult(); + + // Call + SerializableTotalAssemblyResult serializableTotalAssembly = + SerializableTotalAssemblyResultCreator.Create(idGenerator, + serializableAssessmentProcess, + failureMechanismAssemblyResultWithProbability, + failureMechanismAssemblyResultWithoutProbability, + assessmentSectionAssemblyResult); + + // Assert + Assert.AreEqual("0", serializableTotalAssembly.Id); + Assert.AreEqual(serializableAssessmentProcess.Id, serializableTotalAssembly.AssessmentProcessId); + Assert.AreSame(failureMechanismAssemblyResultWithProbability, serializableTotalAssembly.AssemblyResultWithProbability); + Assert.AreSame(failureMechanismAssemblyResultWithoutProbability, serializableTotalAssembly.AssemblyResultWithoutProbability); + Assert.AreSame(assessmentSectionAssemblyResult, serializableTotalAssembly.AssessmentSectionAssemblyResult); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj =================================================================== diff -u -r5ec6a3a075e322e2ca2eddfaf5b3a3f3a2413522 -r533c09fa374c801775800668d9046f9470db2f07 --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 5ec6a3a075e322e2ca2eddfaf5b3a3f3a2413522) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 533c09fa374c801775800668d9046f9470db2f07) @@ -39,6 +39,7 @@ +