Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs =================================================================== diff -u -r2cdd64c04b5525258950cf336810e447bb763740 -r625cf3d63b43ca2bdd3743c22b4a3df9676047d0 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs (.../SerializableAssembly.cs) (revision 2cdd64c04b5525258950cf336810e447bb763740) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs (.../SerializableAssembly.cs) (revision 625cf3d63b43ca2bdd3743c22b4a3df9676047d0) @@ -93,6 +93,7 @@ [XmlArray(AssemblyXmlIdentifiers.FeatureMember)] [XmlArrayItem(typeof(SerializableAssessmentProcess))] [XmlArrayItem(typeof(SerializableAssessmentSection))] + [XmlArrayItem(typeof(SerializableTotalAssemblyResult))] public List FeatureMembers { get; set; } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableTotalAssemblyResult.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableTotalAssemblyResult.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableTotalAssemblyResult.cs (revision 625cf3d63b43ca2bdd3743c22b4a3df9676047d0) @@ -0,0 +1,102 @@ +// 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.Xml.Serialization; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; + +namespace Ringtoets.AssemblyTool.IO.Model +{ + /// + /// Class describing a serializable total assembly result. + /// + [XmlType(AssemblyXmlIdentifiers.TotalAssemblyResult)] + public class SerializableTotalAssemblyResult : SerializableFeatureMember + { + /// + /// Creates a new instance of . + /// + public SerializableTotalAssemblyResult() {} + + /// + /// Creates a new instance of . + /// + /// The unique ID of the assembly result. + /// The assessment process this result belongs to. + /// The assembly result for failure mechanisms with a probability. + /// The assembly result for failure mechanisms without a probablilty. + /// Thrown when any parameter is null. + public SerializableTotalAssemblyResult(string id, + SerializableAssessmentProcess assessmentProcess, + SerializableFailureMechanismAssemblyResult assemblyResultWithoutProbability, + SerializableFailureMechanismAssemblyResult assemblyResultWithProbability) : this() + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + + if (assessmentProcess == null) + { + throw new ArgumentNullException(nameof(assessmentProcess)); + } + + if (assemblyResultWithoutProbability == null) + { + throw new ArgumentNullException(nameof(assemblyResultWithoutProbability)); + } + + if (assemblyResultWithProbability == null) + { + throw new ArgumentNullException(nameof(assemblyResultWithProbability)); + } + + Id = id; + AssessmentProcessId = assessmentProcess.Id; + AssemblyResultWithoutProbability = assemblyResultWithoutProbability; + AssemblyResultWithProbability = assemblyResultWithProbability; + } + + /// + /// Gets or sets the ID. + /// + [XmlAttribute(AssemblyXmlIdentifiers.TotalAssemblyResultId)] + public string Id { get; set; } + + /// + /// Gets or sets the parent assessment process ID. + /// + [XmlAttribute(AssemblyXmlIdentifiers.AssessmentProcessIdRef)] + public string AssessmentProcessId { get; set; } + + /// + /// Gets or sets the assembly result with probability. + /// + [XmlElement(AssemblyXmlIdentifiers.AssemblyResultWithProbability)] + public SerializableFailureMechanismAssemblyResult AssemblyResultWithProbability { get; set; } + + /// + /// Gets or sets the assembly result without probability. + /// + [XmlElement(AssemblyXmlIdentifiers.AssemblyResultWithoutProbability)] + public SerializableFailureMechanismAssemblyResult AssemblyResultWithoutProbability { get; set; } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj =================================================================== diff -u -r3c6655d802e8c8a7f1b3fec37e96778fedb3f278 -r625cf3d63b43ca2bdd3743c22b4a3df9676047d0 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision 3c6655d802e8c8a7f1b3fec37e96778fedb3f278) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision 625cf3d63b43ca2bdd3743c22b4a3df9676047d0) @@ -24,6 +24,7 @@ + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs =================================================================== diff -u -r4370689b5b8ddbdcbec2c0632ca7cf4220851eac -r625cf3d63b43ca2bdd3743c22b4a3df9676047d0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (.../SerializableAssemblyTest.cs) (revision 4370689b5b8ddbdcbec2c0632ca7cf4220851eac) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (.../SerializableAssemblyTest.cs) (revision 625cf3d63b43ca2bdd3743c22b4a3df9676047d0) @@ -21,13 +21,16 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Xml.Serialization; using Core.Common.Base.Geometry; using Core.Common.Util.Reflection; using NUnit.Framework; using Ringtoets.AssemblyTool.IO.Model; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; +using Ringtoets.AssemblyTool.IO.Model.Enums; using Ringtoets.AssemblyTool.IO.TestUtil; namespace Ringtoets.AssemblyTool.IO.Test.Model @@ -63,9 +66,10 @@ Assert.AreEqual("featureMember", xmlArrayAttribute.ElementName); IEnumerable xmlArrayItemAttributes = TypeUtils.GetPropertyAttributes(nameof(SerializableAssembly.FeatureMembers)); - Assert.AreEqual(2, xmlArrayItemAttributes.Count()); + Assert.AreEqual(3, xmlArrayItemAttributes.Count()); Assert.AreEqual(typeof(SerializableAssessmentProcess), xmlArrayItemAttributes.ElementAt(0).Type); Assert.AreEqual(typeof(SerializableAssessmentSection), xmlArrayItemAttributes.ElementAt(1).Type); + Assert.AreEqual(typeof(SerializableTotalAssemblyResultTest), xmlArrayItemAttributes.ElementAt(2).Type); } [Test] @@ -155,8 +159,10 @@ }); // Assert Assert.AreEqual(id, assembly.Id); - Assert.AreEqual(lowerCorner.X + " " + lowerCorner.Y, assembly.Boundary.Envelope.LowerCorner); - Assert.AreEqual(upperCorner.X + " " + upperCorner.Y, assembly.Boundary.Envelope.UpperCorner); + Assert.AreEqual(lowerCorner.X.ToString(CultureInfo.InvariantCulture) + " " + lowerCorner.Y.ToString(CultureInfo.InvariantCulture), + assembly.Boundary.Envelope.LowerCorner); + Assert.AreEqual(upperCorner.X.ToString(CultureInfo.InvariantCulture) + " " + upperCorner.Y.ToString(CultureInfo.InvariantCulture), + assembly.Boundary.Envelope.UpperCorner); Assert.AreSame(featureMember, assembly.FeatureMembers.Single()); } @@ -181,21 +187,28 @@ Name = "Traject A", SurfaceLineGeometry = new SerializableLine(new[] { - new Point2D(0.0, 10.0), - new Point2D(10.0, 20.0) + new Point2D(0.35, 10.642), + new Point2D(10.1564, 20.23) }) }; var assessmentProcess = new SerializableAssessmentProcess("process1", - assessmentSection, - 2018, - 2020); + assessmentSection, + 2018, + 2020); - var assembly = new SerializableAssembly("assembly_1", new Point2D(12.0, 34.0), new Point2D(56.0, 78.0), + var totalAssemblyResult = new SerializableTotalAssemblyResult( + "total id", + assessmentProcess, + new SerializableFailureMechanismAssemblyResult(AssemblyMethod.WBI2B1, SerializableFailureMechanismCategoryGroup.IIt), + new SerializableFailureMechanismAssemblyResult(AssemblyMethod.WBI3C1, SerializableFailureMechanismCategoryGroup.NotApplicable, 0.000124)); + + var assembly = new SerializableAssembly("assembly_1", new Point2D(12.0, 34.0), new Point2D(56.053, 78.0002345), new List { assessmentSection, - assessmentProcess + assessmentProcess, + totalAssemblyResult }); serializer.Serialize(writer, assembly, xmlns); Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableTotalAssemblyResultTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableTotalAssemblyResultTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableTotalAssemblyResultTest.cs (revision 625cf3d63b43ca2bdd3743c22b4a3df9676047d0) @@ -0,0 +1,140 @@ +// 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.AssemblyTool.IO.TestUtil; + +namespace Ringtoets.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class SerializableTotalAssemblyResultTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var totalAssemblyResult = new SerializableTotalAssemblyResult(); + + // Assert + Assert.IsInstanceOf(totalAssemblyResult); + Assert.IsNull(totalAssemblyResult.Id); + Assert.IsNull(totalAssemblyResult.AssessmentProcessId); + Assert.IsNull(totalAssemblyResult.AssemblyResultWithProbability); + Assert.IsNull(totalAssemblyResult.AssemblyResultWithoutProbability); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableTotalAssemblyResult.Id), "VeiligheidsoordeelID"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableTotalAssemblyResult.AssessmentProcessId), "BeoordelingsprocesIDRef"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableTotalAssemblyResult.AssemblyResultWithProbability), "toetsoordeelMetKansschatting"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableTotalAssemblyResult.AssemblyResultWithoutProbability), "toetsoordeelZonderKansschatting"); + } + + [Test] + public void Constructor_IdNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableTotalAssemblyResult(null, + new SerializableAssessmentProcess(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("id", exception.ParamName); + } + + [Test] + public void Constructor_AssessmentProcessNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableTotalAssemblyResult("id", + null, + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentProcess", exception.ParamName); + } + + [Test] + public void Constructor_AssemblyResultWithoutProbabilityNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableTotalAssemblyResult("id", + new SerializableAssessmentProcess(), + null, + new SerializableFailureMechanismAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assemblyResultWithoutProbability", exception.ParamName); + } + + [Test] + public void Constructor_AssemblyResultWithProbabilityNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableTotalAssemblyResult("id", + new SerializableAssessmentProcess(), + new SerializableFailureMechanismAssemblyResult(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assemblyResultWithProbability", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "id"; + + var random = new Random(39); + var assessmentProcess = new SerializableAssessmentProcess("process id", + new SerializableAssessmentSection(), + random.Next(), + random.Next()); + var resultWithoutProbability = new SerializableFailureMechanismAssemblyResult(); + var resultWithProbability = new SerializableFailureMechanismAssemblyResult(); + + // Call + var totalAssemblyResult = new SerializableTotalAssemblyResult(id, + assessmentProcess, + resultWithoutProbability, + resultWithProbability); + + // Assert + Assert.AreEqual(id, totalAssemblyResult.Id); + Assert.AreEqual(assessmentProcess.Id, totalAssemblyResult.AssessmentProcessId); + Assert.AreSame(resultWithoutProbability, totalAssemblyResult.AssemblyResultWithoutProbability); + Assert.AreSame(resultWithProbability, totalAssemblyResult.AssemblyResultWithProbability); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj =================================================================== diff -u -r3c6655d802e8c8a7f1b3fec37e96778fedb3f278 -r625cf3d63b43ca2bdd3743c22b4a3df9676047d0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision 3c6655d802e8c8a7f1b3fec37e96778fedb3f278) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision 625cf3d63b43ca2bdd3743c22b4a3df9676047d0) @@ -20,6 +20,7 @@ +