Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/AssemblyXmlIdentifiers.cs =================================================================== diff -u -rb0b566f39d1154e82c2cc098318ad18bf70342e8 -r5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/AssemblyXmlIdentifiers.cs (.../AssemblyXmlIdentifiers.cs) (revision b0b566f39d1154e82c2cc098318ad18bf70342e8) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/AssemblyXmlIdentifiers.cs (.../AssemblyXmlIdentifiers.cs) (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -123,6 +123,11 @@ public const string DirectFailureMechanism = "typeFaalmechanisme"; /// + /// Identifier for an end distance element. + /// + public const string EndDistance = "afstandEinde"; + + /// /// Identifier for an end year element. /// public const string EndYear = "eindJaarBeoordelingsronde"; @@ -153,6 +158,11 @@ public const string FailureMechanismIdRef = "ToetsspoorIDRef"; /// + /// Identifier for a failure mechanism section element. + /// + public const string FailureMechanismSection = "Waterkeringsectie"; + + /// /// Identifier for a failure mechanism section assembly element. /// public const string FailureMechanismSectionAssemblyResult = "Toets"; @@ -183,6 +193,11 @@ public const string FailureMechanismSectionsIdRef = "VakindelingIDRef"; /// + /// Identifier for a failure mechanism section type element. + /// + public const string FailureMechanismSectionType = "typeWaterkeringsectie"; + + /// /// Identifier for a failure mechanism group element. /// public const string FailureMechanismType = "typeToetsspoor"; @@ -203,6 +218,11 @@ public const string Geometry2D = "geometrie2D"; /// + /// Identifier for a 2D line geometry element. + /// + public const string GeometryLine2D = "geometrieLijn2D"; + + /// /// The XML namespace for GML objects. /// public const string GmlNamespace = "http://www.opengis.net/gml/3.2"; @@ -243,6 +263,11 @@ public const string SectionResults = "toetsoordeelVak"; /// + /// Identifier for a start distance element. + /// + public const string StartDistance = "afstandBegin"; + + /// /// Identifier for a start year element. /// public const string StartYear = "beginJaarBeoordelingsronde"; Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs =================================================================== diff -u -rc37e7aa9fdd38a0476335e056b33c583486ed1af -r5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs (.../SerializableAssembly.cs) (revision c37e7aa9fdd38a0476335e056b33c583486ed1af) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssembly.cs (.../SerializableAssembly.cs) (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -96,6 +96,7 @@ [XmlArrayItem(typeof(SerializableFailureMechanism))] [XmlArrayItem(typeof(SerializableFailureMechanismSectionAssembly))] [XmlArrayItem(typeof(SerializableFailureMechanismSections))] + [XmlArrayItem(typeof(SerializableFailureMechanismSection))] public SerializableFeatureMember[] FeatureMembers { get; set; } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentSection.cs =================================================================== diff -u -r7a9324ff54b5ca989a0c5a535c3f45dec74417bb -r5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentSection.cs (.../SerializableAssessmentSection.cs) (revision 7a9324ff54b5ca989a0c5a535c3f45dec74417bb) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentSection.cs (.../SerializableAssessmentSection.cs) (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -40,7 +40,6 @@ public SerializableAssessmentSection() { AssessmentSectionType = Resources.AssessmentSectionType; - SurfaceLineLength = new SerializableMeasure("m", double.NaN); } /// Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSection.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSection.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableFailureMechanismSection.cs (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -0,0 +1,125 @@ +// 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 Core.Common.Base.Geometry; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; +using Ringtoets.AssemblyTool.IO.Properties; + +namespace Ringtoets.AssemblyTool.IO.Model +{ + /// + /// Class describing a serializable failure mechanism section object. + /// + [XmlType(AssemblyXmlIdentifiers.FailureMechanismSection)] + public class SerializableFailureMechanismSection : SerializableFeatureMember + { + /// + /// Creates a new instance of . + /// + public SerializableFailureMechanismSection() + { + FailureMechanismSectionType = Resources.FailureMechanismSectionType_FailureMechanism; + } + + /// + /// Creates a new instance of . + /// + /// The unique ID of the section. + /// The failure mechanism sections object the section belong to. + /// The distance over the reference line where this section starts. + /// The distance over the reference line where this section ends. + /// The geometry of the section. + /// Thrown when any parameter is null. + public SerializableFailureMechanismSection(string id, + SerializableFailureMechanismSections failureMechanismSections, + double startDistance, + double endDistance, + IEnumerable geometry) : this() + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + + if (failureMechanismSections == null) + { + throw new ArgumentNullException(nameof(failureMechanismSections)); + } + + if (geometry == null) + { + throw new ArgumentNullException(nameof(geometry)); + } + + Id = id; + StartDistance = new SerializableMeasure("m", startDistance); + EndDistance = new SerializableMeasure("m", endDistance); + FailureMechanismSectionsId = failureMechanismSections.Id; + Geometry = new SerializableLine(geometry); + Length = new SerializableMeasure("m", Math2D.Length(geometry)); + } + + /// + /// Gets or sets the ID. + /// + [XmlAttribute(AssemblyXmlIdentifiers.Id, Namespace = AssemblyXmlIdentifiers.GmlNamespace)] + public string Id { get; set; } + + /// + /// Gets or sets the ID of the parent failure mechanism sections. + /// + [XmlAttribute(AssemblyXmlIdentifiers.FailureMechanismSectionsIdRef)] + public string FailureMechanismSectionsId { get; set; } + + /// + /// Gets or sets the section starting distance. + /// + [XmlElement(AssemblyXmlIdentifiers.StartDistance)] + public SerializableMeasure StartDistance { get; set; } + + /// + /// Gets or sets the section ending distance. + /// + [XmlElement(AssemblyXmlIdentifiers.EndDistance)] + public SerializableMeasure EndDistance { get; set; } + + /// + /// Gets or sets the section geometry. + /// + [XmlElement(AssemblyXmlIdentifiers.GeometryLine2D)] + public SerializableLine Geometry { get; set; } + + /// + /// Gets or sets the section length. + /// + [XmlElement(AssemblyXmlIdentifiers.Length)] + public SerializableMeasure Length { get; set; } + + /// + /// Gets or sets the section type. + /// + [XmlElement(AssemblyXmlIdentifiers.FailureMechanismSectionType)] + public string FailureMechanismSectionType { get; set; } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Properties/Resources.Designer.cs =================================================================== diff -u -rbb161675859d33b5bd868b5679b2cb09a6871b2d -r5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision bb161675859d33b5bd868b5679b2cb09a6871b2d) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -100,6 +100,24 @@ } /// + /// Looks up a localized string similar to GECBNETSSTE. + /// + internal static string FailureMechanismSectionType_Combined { + get { + return ResourceManager.GetString("FailureMechanismSectionType_Combined", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to TOETSSSTE. + /// + internal static string FailureMechanismSectionType_FailureMechanism { + get { + return ResourceManager.GetString("FailureMechanismSectionType_FailureMechanism", resourceCulture); + } + } + + /// /// Looks up a localized string similar to VOLLDG. /// internal static string FullAssembly { Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Properties/Resources.resx =================================================================== diff -u -rbb161675859d33b5bd868b5679b2cb09a6871b2d -r5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Properties/Resources.resx (.../Resources.resx) (revision bb161675859d33b5bd868b5679b2cb09a6871b2d) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Properties/Resources.resx (.../Resources.resx) (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -123,6 +123,12 @@ DIRECT + + GECBNETSSTE + + + TOETSSSTE + VOLLDG Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj =================================================================== diff -u -rb0b566f39d1154e82c2cc098318ad18bf70342e8 -r5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision b0b566f39d1154e82c2cc098318ad18bf70342e8) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -29,6 +29,7 @@ + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs =================================================================== diff -u -rc37e7aa9fdd38a0476335e056b33c583486ed1af -r5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (.../SerializableAssemblyTest.cs) (revision c37e7aa9fdd38a0476335e056b33c583486ed1af) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (.../SerializableAssemblyTest.cs) (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -66,13 +66,14 @@ Assert.AreEqual("featureMember", xmlArrayAttribute.ElementName); IEnumerable xmlArrayItemAttributes = TypeUtils.GetPropertyAttributes(nameof(SerializableAssembly.FeatureMembers)); - Assert.AreEqual(6, xmlArrayItemAttributes.Count()); + Assert.AreEqual(7, 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); Assert.AreEqual(typeof(SerializableFailureMechanismSections), xmlArrayItemAttributes.ElementAt(5).Type); + Assert.AreEqual(typeof(SerializableFailureMechanismSection), xmlArrayItemAttributes.ElementAt(6).Type); } [Test] @@ -156,7 +157,7 @@ var assembly = new SerializableAssembly(id, lowerCorner, upperCorner, - new[] + new SerializableFeatureMember[] { featureMember }); @@ -213,6 +214,15 @@ new SerializableFailureMechanismAssemblyResult(SerializableAssemblyMethod.WBI1A1, SerializableFailureMechanismCategoryGroup.IIt)); var sections1 = new SerializableFailureMechanismSections("sections1", failureMechanism1); + var section1 = new SerializableFailureMechanismSection("s1", + sections1, + 0.12, + 10.23, + new[] + { + new Point2D(0.23, 0.24), + new Point2D(10.23, 10.24) + }); var result1 = new SerializableFailureMechanismSectionAssembly("sr1", failureMechanism1, @@ -231,7 +241,8 @@ totalAssemblyResult, failureMechanism1, result1, - sections1 + sections1, + section1 }); serializer.Serialize(writer, assembly, xmlns); Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs =================================================================== diff -u -r7f2399453f788c27181ea2b857a6cad170e78179 -r5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs (.../SerializableAssessmentSectionTest.cs) (revision 7f2399453f788c27181ea2b857a6cad170e78179) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs (.../SerializableAssessmentSectionTest.cs) (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -43,8 +43,7 @@ Assert.IsNull(assessmentSection.Id); Assert.IsNull(assessmentSection.Name); Assert.IsNull(assessmentSection.SurfaceLineGeometry); - Assert.IsNaN(assessmentSection.SurfaceLineLength.Value); - Assert.AreEqual("m", assessmentSection.SurfaceLineLength.UnitOfMeasure); + Assert.IsNull(assessmentSection.SurfaceLineLength); SerializableAttributeTestHelper.AssertXmlAttributeAttribute( nameof(SerializableAssessmentSection.Id), "id", "http://www.opengis.net/gml/3.2"); Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionTest.cs (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -0,0 +1,157 @@ +// 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.Linq; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.Model; +using Ringtoets.AssemblyTool.IO.Model.Helpers; +using Ringtoets.AssemblyTool.IO.TestUtil; + +namespace Ringtoets.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class SerializableFailureMechanismSectionTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var section = new SerializableFailureMechanismSection(); + + // Assert + Assert.IsInstanceOf(section); + Assert.IsNull(section.Id); + Assert.IsNull(section.FailureMechanismSectionsId); + Assert.IsNull(section.StartDistance); + Assert.IsNull(section.EndDistance); + Assert.IsNull(section.Geometry); + Assert.AreEqual("TOETSSSTE", section.FailureMechanismSectionType); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSection.Id), "id", "http://www.opengis.net/gml/3.2"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSection.FailureMechanismSectionsId), "VakindelingIDRef"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSection.StartDistance), "afstandBegin"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSection.EndDistance), "afstandEinde"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSection.Geometry), "geometrieLijn2D"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSection.Length), "lengte"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSection.FailureMechanismSectionType), "typeWaterkeringsectie"); + } + + [Test] + public void Constructor_IdNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableFailureMechanismSection(null, + new SerializableFailureMechanismSections(), + random.NextDouble(), + random.NextDouble(), + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("id", exception.ParamName); + } + + [Test] + public void Constructor_FailureMechanismSectionsNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableFailureMechanismSection("id", + null, + random.NextDouble(), + random.NextDouble(), + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSections", exception.ParamName); + } + + [Test] + public void Constructor_GeometryNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableFailureMechanismSection("id", + new SerializableFailureMechanismSections(), + random.NextDouble(), + random.NextDouble(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("geometry", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "section id"; + + var random = new Random(39); + var sections = new SerializableFailureMechanismSections("sections id", new SerializableFailureMechanism()); + double startDistance = random.NextDouble(); + double endDistance = random.NextDouble(); + var geometry = new[] + { + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()) + }; + + // Call + var section = new SerializableFailureMechanismSection(id, + sections, + startDistance, + endDistance, + geometry); + + // Assert + Assert.AreEqual(id, section.Id); + Assert.AreEqual(sections.Id, section.FailureMechanismSectionsId); + Assert.AreEqual("m", section.StartDistance.UnitOfMeasure); + Assert.AreEqual(startDistance, section.StartDistance.Value); + Assert.AreEqual("m", section.EndDistance.UnitOfMeasure); + Assert.AreEqual(endDistance, section.EndDistance.Value); + Assert.AreEqual(GeometrySerializationFormatter.Format(geometry), section.Geometry.LineString.Geometry); + Assert.AreEqual("m", section.Length.UnitOfMeasure); + Assert.AreEqual(Math2D.Length(geometry), section.Length.Value); + Assert.AreEqual("TOETSSSTE", section.FailureMechanismSectionType); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj =================================================================== diff -u -rb0b566f39d1154e82c2cc098318ad18bf70342e8 -r5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision b0b566f39d1154e82c2cc098318ad18bf70342e8) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision 5c59e60cae7bc68b321c0ee187a7d4dd9dd753b2) @@ -25,6 +25,7 @@ +