Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentSection.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentSection.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/SerializableAssessmentSection.cs (revision 2ca62c7a47e05e211f93e7f10fb121eecd264470) @@ -0,0 +1,110 @@ +// 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.Properties; + +namespace Ringtoets.AssemblyTool.IO.Model +{ + /// + /// Class describing a serializable assessment section. + /// + [XmlType(AssemblyXmlIdentifiers.AssessmentSection)] + public class SerializableAssessmentSection : SerializableFeatureMember + { + /// + /// Creates a new instance of . + /// + public SerializableAssessmentSection() + { + AssessmentSectionType = Resources.AssessmentSectionType; + SurfaceLineLength = new SerializableMeasure("m", double.NaN); + } + + /// + /// Creates a new instance of . + /// + /// The unique ID of the assessment section. + /// The name of the assessment section. + /// The length of the surface line in meters. + /// The geometry of the surface line. + /// Thrown when any parameter is null. + public SerializableAssessmentSection(string id, + string name, + double surfaceLineLength, + IEnumerable surfaceLineGeometry) : this() + { + if (id == null) + { + throw new ArgumentNullException(nameof(id)); + } + + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + if (surfaceLineGeometry == null) + { + throw new ArgumentNullException(nameof(surfaceLineGeometry)); + } + + Id = id; + Name = name; + SurfaceLineLength = new SerializableMeasure("m", surfaceLineLength); + SurfaceLineGeometry = new SerializableLine(surfaceLineGeometry); + } + + /// + /// Gets or sets the assessment section ID. + /// + [XmlAttribute(AssemblyXmlIdentifiers.Id, Namespace = AssemblyXmlIdentifiers.GmlNamespace)] + public string Id { get; set; } + + /// + /// Gets or sets the geometry of the surface line. + /// + [XmlElement(AssemblyXmlIdentifiers.Geometry2D)] + public SerializableLine SurfaceLineGeometry { get; set; } + + /// + /// Gets or sets the length of the surface line. + /// [m] + /// + [XmlElement(AssemblyXmlIdentifiers.Length)] + public SerializableMeasure SurfaceLineLength { get; set; } + + /// + /// Gets or sets the name of the assessment section. + /// + [XmlElement(AssemblyXmlIdentifiers.Name)] + public string Name { get; set; } + + /// + /// Gets or sets the type of the assessment section. + /// + [XmlElement(AssemblyXmlIdentifiers.AssessmentSectionType)] + public string AssessmentSectionType { get; set; } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs =================================================================== diff -u -rf79dd2e1f821a759c13b3576e09532105789a05d -r2ca62c7a47e05e211f93e7f10fb121eecd264470 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (.../SerializableAssemblyTest.cs) (revision f79dd2e1f821a759c13b3576e09532105789a05d) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (.../SerializableAssemblyTest.cs) (revision 2ca62c7a47e05e211f93e7f10fb121eecd264470) @@ -173,7 +173,7 @@ var assessmentSection = new SerializableAssessmentSection { Id = "section1", - Length = new SerializableMeasure + SurfaceLineLength = new SerializableMeasure { UnitOfMeasure = "m", Value = 100 Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs (revision 2ca62c7a47e05e211f93e7f10fb121eecd264470) @@ -0,0 +1,129 @@ +// 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.TestUtil; + +namespace Ringtoets.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class SerializableAssessmentSectionTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var assessmentSection = new SerializableAssessmentSection(); + + // Assert + Assert.AreEqual("Dijktraject", assessmentSection.AssessmentSectionType); + Assert.IsNull(assessmentSection.Id); + Assert.IsNull(assessmentSection.Name); + Assert.IsNull(assessmentSection.SurfaceLineGeometry); + Assert.IsNaN(assessmentSection.SurfaceLineLength.Value); + Assert.AreEqual("m", assessmentSection.SurfaceLineLength.UnitOfMeasure); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableAssessmentSection.Id), "id", "http://www.opengis.net/gml/3.2"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentSection.AssessmentSectionType), "typeWaterkeringstelsel"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentSection.Name), "naam"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentSection.SurfaceLineLength), "lengte"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentSection.SurfaceLineGeometry), "geometrie2D"); + } + + [Test] + public void Constructor_IdNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableAssessmentSection(null, + "name", + new Random(39).NextDouble(), + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("id", exception.ParamName); + } + + [Test] + public void Constructor_NameNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableAssessmentSection("id", + null, + new Random(39).NextDouble(), + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("name", exception.ParamName); + } + + [Test] + public void Constructor_SurfaceLineGeometryNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableAssessmentSection("id", + "name", + new Random(39).NextDouble(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("surfaceLineGeometry", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string name = "section name"; + const string id = "section id"; + + var random = new Random(39); + double length = random.NextDouble(); + var geometry = new[] + { + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()) + }; + + // Call + var assessmentSection = new SerializableAssessmentSection(id, name, length, geometry); + + // Assert + Assert.AreEqual(id, assessmentSection.Id); + Assert.AreEqual(name, assessmentSection.Name); + Assert.AreEqual("m", assessmentSection.SurfaceLineLength.UnitOfMeasure); + Assert.AreEqual(length, assessmentSection.SurfaceLineLength.Value); + Assert.IsNotNull(assessmentSection.SurfaceLineGeometry); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj =================================================================== diff -u -re382cd31f8112438e24bd25ff1c429cf8b5fba4d -r2ca62c7a47e05e211f93e7f10fb121eecd264470 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision e382cd31f8112438e24bd25ff1c429cf8b5fba4d) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision 2ca62c7a47e05e211f93e7f10fb121eecd264470) @@ -15,6 +15,7 @@ +