Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/AssemblyXmlIdentifiers.cs =================================================================== diff -u -re86f09313f6e47b9b35bb8808e6c3dad55d73177 -r7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/AssemblyXmlIdentifiers.cs (.../AssemblyXmlIdentifiers.cs) (revision e86f09313f6e47b9b35bb8808e6c3dad55d73177) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/AssemblyXmlIdentifiers.cs (.../AssemblyXmlIdentifiers.cs) (revision 7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e) @@ -91,26 +91,6 @@ /// Identifier for an assessment section element. /// public const string AssessmentSection = "Waterkeringstelsel"; - - /// - /// Identifier for an assessment section total assembly result element. - /// - public const string AssessmentSectionAssemblyResult = "ToetsoordeelTraject"; - - /// - /// Identifier for an assessment section total assembly result element. - /// - public const string TotalAssemblyResult = "Veiligheidsoordeel"; - - /// - /// Identifier for an assessment section assembly result ID attribute. - /// - public const string TotalAssemblyResultId = "VeiligheidsoordeelID"; - - /// - /// Identifier for an assessment section assembly result ID reference attribute. - /// - public const string TotalAssemblyResultIdRef = "VeiligheidsoordeelIDRef"; /// /// Identifier for an assessment section category group element. @@ -123,6 +103,11 @@ public const string BoundedBy = "boundedBy"; /// + /// Identifier for a combined section result element. + /// + public const string CombinedSectionResult = "eindtoetsoordeel"; + + /// /// Identifier for a coordinate system type attribute. /// public const string CoordinateSystem = "srsName"; @@ -158,11 +143,26 @@ public const string FailureMechanismAssemblyResult = "toetsoordeel"; /// - /// Identifier for a failure mechanism id attribute. + /// Identifier for a failure mechanism ID attribute. /// public const string FailureMechanismId = "ToetsspoorID"; + + /// + /// Identifier for a failure mechanism ID reference attribute. + /// + public const string FailureMechanismIdRef = "ToetsspoorIDRef"; /// + /// Identifier for a failure mechanism section assembly element. + /// + public const string FailureMechanismSectionAssemblyResult = "Toets"; + + /// + /// Identifier for a failure mechanism section assembly element. + /// + public const string FailureMechanismSectionAssemblyResultId = "ToetsID"; + + /// /// Identifier for a failure mechanism section category group element. /// public const string FailureMechanismSectionCategoryGroup = "categorieVak"; @@ -223,6 +223,11 @@ public const string Probability = "faalkans"; /// + /// Identifier for section result elements. + /// + public const string SectionResults = "toetsoordeelVak"; + + /// /// Identifier for a start year element. /// public const string StartYear = "beginJaarBeoordelingsronde"; @@ -233,6 +238,21 @@ public const string Status = "status"; /// + /// Identifier for an assessment section total assembly result element. + /// + public const string TotalAssemblyResult = "Veiligheidsoordeel"; + + /// + /// Identifier for an assessment section assembly result ID attribute. + /// + public const string TotalAssemblyResultId = "VeiligheidsoordeelID"; + + /// + /// Identifier for an assessment section assembly result ID reference attribute. + /// + public const string TotalAssemblyResultIdRef = "VeiligheidsoordeelIDRef"; + + /// /// Identifier for a unit of measure attribute. /// public const string UnitOfMeasure = "uom"; Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs =================================================================== diff -u -ra68114e88ef61d5068037461aa2dd7e38a23f16a -r7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs (.../SerializableAssembly.cs) (revision a68114e88ef61d5068037461aa2dd7e38a23f16a) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs (.../SerializableAssembly.cs) (revision 7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e) @@ -95,6 +95,7 @@ [XmlArrayItem(typeof(SerializableAssessmentSection))] [XmlArrayItem(typeof(SerializableTotalAssemblyResult))] [XmlArrayItem(typeof(SerializableFailureMechanism))] + [XmlArrayItem(typeof(SerializableFailureMechanismSectionAssembly))] public List FeatureMembers { get; set; } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanism.cs =================================================================== diff -u -ra68114e88ef61d5068037461aa2dd7e38a23f16a -r7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanism.cs (.../SerializableFailureMechanism.cs) (revision a68114e88ef61d5068037461aa2dd7e38a23f16a) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanism.cs (.../SerializableFailureMechanism.cs) (revision 7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e) @@ -45,13 +45,13 @@ /// Creates a new instance of . /// /// The unique ID of the assembly result. - /// The ID of the parent . + /// The total assembly result this failure mechanism belongs to. /// The type of the failure mechanism. /// The group of the failure mechanism. /// The total failure mechanism assembly result. /// Thrown when any parameter is null. public SerializableFailureMechanism(string id, - SerializableTotalAssemblyResult parentTotalAssemblyResult, + SerializableTotalAssemblyResult totalAssemblyResult, SerializableFailureMechanismType failureMechanismType, SerializableAssemblyGroup assemblyGroup, SerializableFailureMechanismAssemblyResult failureMechanismAssemblyResult) : this() @@ -61,9 +61,9 @@ throw new ArgumentNullException(nameof(id)); } - if (parentTotalAssemblyResult == null) + if (totalAssemblyResult == null) { - throw new ArgumentNullException(nameof(parentTotalAssemblyResult)); + throw new ArgumentNullException(nameof(totalAssemblyResult)); } if (failureMechanismAssemblyResult == null) @@ -72,7 +72,7 @@ } Id = id; - TotalAssemblyResultId = parentTotalAssemblyResult.Id; + TotalAssemblyResultId = totalAssemblyResult.Id; FailureMechanismType = failureMechanismType; AssemblyGroup = assemblyGroup; FailureMechanismAssemblyResult = failureMechanismAssemblyResult; Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSectionAssembly.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSectionAssembly.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSectionAssembly.cs (revision 7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e) @@ -0,0 +1,104 @@ +// 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.Collections.Generic; +using System.Xml.Serialization; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; + +namespace Ringtoets.AssemblyTool.IO.Model +{ + /// + /// Class describing a serializable failure mechanism section assembly result. + /// + [XmlType(AssemblyXmlIdentifiers.FailureMechanismSectionAssemblyResult)] + public class SerializableFailureMechanismSectionAssembly : SerializableFeatureMember + { + /// + /// Creates a new instance of . + /// + public SerializableFailureMechanismSectionAssembly() {} + + /// + /// Creates a new instance of . + /// + /// The unique ID of the assembly result. + /// The failure mechanism this assembly belongs to. + /// The collection of assembly results for this section assembly. + /// The combined assembly result for this section assembly. + /// Thrown when any parameter is null. + public SerializableFailureMechanismSectionAssembly(string id, + SerializableFailureMechanism failureMechanism, + List sectionResults, + SerializableFailureMechanismSectionAssemblyResult combinedSectionResult) : this() + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (sectionResults == null) + { + throw new ArgumentNullException(nameof(sectionResults)); + } + + if (combinedSectionResult == null) + { + throw new ArgumentNullException(nameof(combinedSectionResult)); + } + + Id = id; + FailureMechanismId = failureMechanism.Id; + SectionResults = sectionResults; + CombinedSectionResult = combinedSectionResult; + } + + /// + /// Gets or sets the ID. + /// + [XmlAttribute(AssemblyXmlIdentifiers.FailureMechanismSectionAssemblyResultId)] + public string Id { get; set; } + + /// + /// Gets or sets the parent failure mechanism ID. + /// + [XmlAttribute(AssemblyXmlIdentifiers.FailureMechanismIdRef)] + public string FailureMechanismId { get; set; } + + /// + /// Gets or sets the combined assembly result. + /// + [XmlElement(AssemblyXmlIdentifiers.CombinedSectionResult)] + public SerializableFailureMechanismSectionAssemblyResult CombinedSectionResult { get; set; } + + /// + /// Gets or sets the list of results for this section. + /// + [XmlElement(AssemblyXmlIdentifiers.SectionResults)] + public List SectionResults { get; set; } + + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj =================================================================== diff -u -re86f09313f6e47b9b35bb8808e6c3dad55d73177 -r7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision e86f09313f6e47b9b35bb8808e6c3dad55d73177) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision 7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e) @@ -30,6 +30,7 @@ + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs =================================================================== diff -u -ra68114e88ef61d5068037461aa2dd7e38a23f16a -r7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (.../SerializableAssemblyTest.cs) (revision a68114e88ef61d5068037461aa2dd7e38a23f16a) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (.../SerializableAssemblyTest.cs) (revision 7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e) @@ -66,11 +66,12 @@ Assert.AreEqual("featureMember", xmlArrayAttribute.ElementName); IEnumerable xmlArrayItemAttributes = TypeUtils.GetPropertyAttributes(nameof(SerializableAssembly.FeatureMembers)); - Assert.AreEqual(4, xmlArrayItemAttributes.Count()); + Assert.AreEqual(5, xmlArrayItemAttributes.Count()); Assert.AreEqual(typeof(SerializableAssessmentProcess), xmlArrayItemAttributes.ElementAt(0).Type); Assert.AreEqual(typeof(SerializableAssessmentSection), xmlArrayItemAttributes.ElementAt(1).Type); Assert.AreEqual(typeof(SerializableTotalAssemblyResult), xmlArrayItemAttributes.ElementAt(2).Type); Assert.AreEqual(typeof(SerializableFailureMechanism), xmlArrayItemAttributes.ElementAt(3).Type); + Assert.AreEqual(typeof(SerializableFailureMechanismSectionAssembly), xmlArrayItemAttributes.ElementAt(4).Type); } [Test] @@ -210,13 +211,23 @@ SerializableAssemblyGroup.Group4, new SerializableFailureMechanismAssemblyResult(SerializableAssemblyMethod.WBI1A1, SerializableFailureMechanismCategoryGroup.IIt)); + var result1 = new SerializableFailureMechanismSectionAssembly("sr1", + failureMechanism1, + new List + { + new SerializableFailureMechanismSectionAssemblyResult(SerializableAssemblyMethod.WBI0E1, SerializableAssessmentLevel.SimpleAssessment, SerializableFailureMechanismSectionCategoryGroup.IIv, 0.5), + new SerializableFailureMechanismSectionAssemblyResult(SerializableAssemblyMethod.WBI0T5, SerializableAssessmentLevel.TailorMadeAssessment, SerializableFailureMechanismSectionCategoryGroup.IIIv) + }, + new SerializableFailureMechanismSectionAssemblyResult(SerializableAssemblyMethod.WBI0A1, SerializableAssessmentLevel.CombinedAssessment, SerializableFailureMechanismSectionCategoryGroup.IIIv)); + var assembly = new SerializableAssembly("assembly_1", new Point2D(12.0, 34.0), new Point2D(56.053, 78.0002345), new List { assessmentSection, assessmentProcess, totalAssemblyResult, - failureMechanism1 + failureMechanism1, + result1 }); serializer.Serialize(writer, assembly, xmlns); Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionAssemblyTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionAssemblyTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionAssemblyTest.cs (revision 7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e) @@ -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 System.Collections.Generic; +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 SerializableFailureMechanismSectionAssemblyTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var sectionAssembly = new SerializableFailureMechanismSectionAssembly(); + + // Assert + Assert.IsInstanceOf(sectionAssembly); + Assert.IsNull(sectionAssembly.Id); + Assert.IsNull(sectionAssembly.FailureMechanismId); + Assert.IsNull(sectionAssembly.CombinedSectionResult); + Assert.IsNull(sectionAssembly.SectionResults); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSectionAssembly.Id), "ToetsID"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSectionAssembly.FailureMechanismId), "ToetsspoorIDRef"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSectionAssembly.CombinedSectionResult), "eindtoetsoordeel"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSectionAssembly.SectionResults), "toetsoordeelVak"); + } + + [Test] + public void Constructor_IdNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableFailureMechanismSectionAssembly(null, + new SerializableFailureMechanism(), + new List(), + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("id", exception.ParamName); + } + + [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableFailureMechanismSectionAssembly("id", + null, + new List(), + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + } + + [Test] + public void Constructor_SectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableFailureMechanismSectionAssembly("id", + new SerializableFailureMechanism(), + null, + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("sectionResults", exception.ParamName); + } + + [Test] + public void Constructor_CombinedSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableFailureMechanismSectionAssembly("id", + new SerializableFailureMechanism(), + new List(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("combinedSectionResult", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "id"; + + var failureMechanism = new SerializableFailureMechanism(); + var sectionResults = new List(); + var combinedSectionResult = new SerializableFailureMechanismSectionAssemblyResult(); + + // Call + var sectionAssembly = new SerializableFailureMechanismSectionAssembly(id, + failureMechanism, + sectionResults, + combinedSectionResult); + + // Assert + Assert.AreEqual(id, sectionAssembly.Id); + Assert.AreEqual(failureMechanism.Id, sectionAssembly.FailureMechanismId); + Assert.AreSame(sectionResults, sectionAssembly.SectionResults); + Assert.AreSame(combinedSectionResult, sectionAssembly.CombinedSectionResult); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismTest.cs =================================================================== diff -u -re86f09313f6e47b9b35bb8808e6c3dad55d73177 -r7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismTest.cs (.../SerializableFailureMechanismTest.cs) (revision e86f09313f6e47b9b35bb8808e6c3dad55d73177) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismTest.cs (.../SerializableFailureMechanismTest.cs) (revision 7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e) @@ -81,7 +81,7 @@ } [Test] - public void Constructor_ParentTotalAssemblyResultNull_ThrowsArgumentNullException() + public void Constructor_TotalAssemblyResultNull_ThrowsArgumentNullException() { // Setup var random = new Random(39); @@ -95,7 +95,7 @@ // Assert var exception = Assert.Throws(call); - Assert.AreEqual("parentTotalAssemblyResult", exception.ParamName); + Assert.AreEqual("totalAssemblyResult", exception.ParamName); } [Test] Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj =================================================================== diff -u -re86f09313f6e47b9b35bb8808e6c3dad55d73177 -r7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision e86f09313f6e47b9b35bb8808e6c3dad55d73177) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision 7deb19aedd02c79cf6ce19e629fec1a6c0ee4e1e) @@ -26,6 +26,7 @@ +