Index: Ringtoets.sln =================================================================== diff -u -rfef9b7f4a9a551e632deb8638ee90b13b0765c60 -r36c991661009852eb8eed4aeb118ffc8b1c2a1f9 --- Ringtoets.sln (.../Ringtoets.sln) (revision fef9b7f4a9a551e632deb8638ee90b13b0765c60) +++ Ringtoets.sln (.../Ringtoets.sln) (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -1977,7 +1977,7 @@ {C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Riskeer.AssemblyTool.IO.Test", "Ringtoets\AssemblyTool\test\Ringtoets.AssemblyTool.IO.Test\Riskeer.AssemblyTool.IO.Test.csproj", "{A85EB391-52B6-410C-B827-82746C618FA0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Riskeer.AssemblyTool.IO.Test", "Ringtoets\AssemblyTool\test\Riskeer.AssemblyTool.IO.Test\Riskeer.AssemblyTool.IO.Test.csproj", "{A85EB391-52B6-410C-B827-82746C618FA0}" ProjectSection(ProjectDependencies) = postProject {C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC} EndProjectSection Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/AssemblyXmlIdentifiersTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/DataTypes/SerializableAssessmentSectionAssemblyResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/DataTypes/SerializableCombinedFailureMechanismSectionAssemblyResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismAssemblyResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismSectionAssemblyResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/DataTypes/SerializableLineTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/DataTypes/SerializableMeasureTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Enums/AssemblyXmlEnumIdentifiersTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Enums/SerializableAssemblyMethodTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Enums/SerializableAssessmentSectionCategoryGroupTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Enums/SerializableAssessmentTypeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismCategoryGroupTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismGroupTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismSectionCategoryGroupTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismSectionTypeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismTypeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Gml/SerializableBoundaryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Gml/SerializableEnvelopeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Gml/SerializableLineStringTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Helpers/GeometrySerializationFormatterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/Helpers/SerializableIdValidatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssessmentProcessTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableCombinedFailureMechanismSectionAssemblyTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionAssemblyTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionCollectionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableFailureMechanismTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/SerializableTotalAssemblyResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Properties/AssemblyInfo.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Riskeer.AssemblyTool.IO.Test.csproj'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/SerializableAssemblyWriterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/test-data/SerializableAssemblyWriterTest/assemblage.xsd'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 36c991661009852eb8eed4aeb118ffc8b1c2a1f9 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/test-data/SerializableAssemblyWriterTest/configuredAssembly.gml'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/AssemblyXmlIdentifiersTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/AssemblyXmlIdentifiersTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/AssemblyXmlIdentifiersTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,110 @@ +// Copyright (C) Stichting Deltares 2018. 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 NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model; + +namespace Riskeer.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class AssemblyXmlIdentifiersTest + { + [Test] + public void AssemblyXmlIdentifiers_ExpectedValues() + { + Assert.AreEqual("Assemblage", AssemblyXmlIdentifiers.Assembly); + Assert.AreEqual("toetsspoorGroep", AssemblyXmlIdentifiers.FailureMechanismGroup); + Assert.AreEqual("toetsoordeelZonderKansschatting", AssemblyXmlIdentifiers.AssemblyResultWithoutProbability); + Assert.AreEqual("toetsoordeelMetKansschatting", AssemblyXmlIdentifiers.AssemblyResultWithProbability); + Assert.AreEqual("http://localhost/standaarden/assemblage", AssemblyXmlIdentifiers.AssemblyNamespace); + Assert.AreEqual("asm", AssemblyXmlIdentifiers.AssemblyNamespaceIdentifier); + Assert.AreEqual("toets", AssemblyXmlIdentifiers.AssessmentType); + Assert.AreEqual("Beoordelingsproces", AssemblyXmlIdentifiers.AssessmentProcess); + Assert.AreEqual("BeoordelingsprocesID", AssemblyXmlIdentifiers.AssessmentProcessId); + Assert.AreEqual("BeoordelingsprocesIDRef", AssemblyXmlIdentifiers.AssessmentProcessIdRef); + Assert.AreEqual("veiligheidsoordeel", AssemblyXmlIdentifiers.AssessmentSectionAssemblyResult); + Assert.AreEqual("categorie", AssemblyXmlIdentifiers.AssessmentSectionCategoryGroup); + Assert.AreEqual("WaterkeringstelselIDRef", AssemblyXmlIdentifiers.AssessmentSectionIdRef); + Assert.AreEqual("typeWaterkeringstelsel", AssemblyXmlIdentifiers.AssessmentSectionType); + Assert.AreEqual("Waterkeringstelsel", AssemblyXmlIdentifiers.AssessmentSection); + + Assert.AreEqual("boundedBy", AssemblyXmlIdentifiers.BoundedBy); + + Assert.AreEqual("GecombineerdToetsoordeel", AssemblyXmlIdentifiers.CombinedFailureMechanismSectionAssembly); + Assert.AreEqual("GecombineerdToetsoordeelID", AssemblyXmlIdentifiers.CombinedFailureMechanismSectionAssemblyId); + Assert.AreEqual("toetsoordeelGecombineerd", AssemblyXmlIdentifiers.CombinedCombinedSectionResult); + Assert.AreEqual("eindtoetsoordeel", AssemblyXmlIdentifiers.CombinedSectionResult); + Assert.AreEqual("eindtoetsoordeelToetsspoor", AssemblyXmlIdentifiers.CombinedSectionFailureMechanismResult); + Assert.AreEqual("srsName", AssemblyXmlIdentifiers.CoordinateSystem); + + Assert.AreEqual("typeFaalmechanisme", AssemblyXmlIdentifiers.DirectFailureMechanism); + + Assert.AreEqual("afstandEinde", AssemblyXmlIdentifiers.EndDistance); + Assert.AreEqual("eindJaarBeoordelingsronde", AssemblyXmlIdentifiers.EndYear); + Assert.AreEqual("Envelope", AssemblyXmlIdentifiers.Envelope); + + Assert.AreEqual("Toetsspoor", AssemblyXmlIdentifiers.FailureMechanism); + Assert.AreEqual("categorieTraject", AssemblyXmlIdentifiers.FailureMechanismCategoryGroup); + Assert.AreEqual("toetsoordeel", AssemblyXmlIdentifiers.FailureMechanismAssemblyResult); + Assert.AreEqual("ToetsspoorID", AssemblyXmlIdentifiers.FailureMechanismId); + Assert.AreEqual("ToetsspoorIDRef", AssemblyXmlIdentifiers.FailureMechanismIdRef); + Assert.AreEqual("ToetsVak", AssemblyXmlIdentifiers.FailureMechanismSection); + Assert.AreEqual("WaterkeringsectieIDRef", AssemblyXmlIdentifiers.FailureMechanismSectionIdRef); + Assert.AreEqual("Toets", AssemblyXmlIdentifiers.FailureMechanismSectionAssembly); + Assert.AreEqual("ToetsID", AssemblyXmlIdentifiers.FailureMechanismSectionAssemblyId); + Assert.AreEqual("categorieVak", AssemblyXmlIdentifiers.FailureMechanismSectionCategoryGroup); + Assert.AreEqual("Vakindeling", AssemblyXmlIdentifiers.FailureMechanismSectionCollection); + Assert.AreEqual("VakindelingID", AssemblyXmlIdentifiers.FailureMechanismSectionCollectionId); + Assert.AreEqual("VakindelingIDRef", AssemblyXmlIdentifiers.FailureMechanismSectionCollectionIdRef); + Assert.AreEqual("typeWaterkeringsectie", AssemblyXmlIdentifiers.FailureMechanismSectionType); + Assert.AreEqual("typeToetsspoor", AssemblyXmlIdentifiers.FailureMechanismType); + Assert.AreEqual("featureMember", AssemblyXmlIdentifiers.FeatureMember); + + Assert.AreEqual("posList", AssemblyXmlIdentifiers.Geometry); + Assert.AreEqual("geometrie2D", AssemblyXmlIdentifiers.Geometry2D); + Assert.AreEqual("geometrieLijn2D", AssemblyXmlIdentifiers.GeometryLine2D); + Assert.AreEqual("http://www.opengis.net/gml/3.2", AssemblyXmlIdentifiers.GmlNamespace); + Assert.AreEqual("gml", AssemblyXmlIdentifiers.GmlNamespaceIdentifier); + + Assert.AreEqual("id", AssemblyXmlIdentifiers.Id); + + Assert.AreEqual("lengte", AssemblyXmlIdentifiers.Length); + Assert.AreEqual("LineString", AssemblyXmlIdentifiers.LineString); + Assert.AreEqual("lowerCorner", AssemblyXmlIdentifiers.LowerCorner); + + Assert.AreEqual("naam", AssemblyXmlIdentifiers.Name); + + Assert.AreEqual("faalkans", AssemblyXmlIdentifiers.Probability); + + Assert.AreEqual("toetsoordeelVak", AssemblyXmlIdentifiers.SectionResults); + Assert.AreEqual("afstandBegin", AssemblyXmlIdentifiers.StartDistance); + Assert.AreEqual("beginJaarBeoordelingsronde", AssemblyXmlIdentifiers.StartYear); + Assert.AreEqual("status", AssemblyXmlIdentifiers.Status); + + Assert.AreEqual("Veiligheidsoordeel", AssemblyXmlIdentifiers.TotalAssemblyResult); + Assert.AreEqual("VeiligheidsoordeelID", AssemblyXmlIdentifiers.TotalAssemblyResultId); + Assert.AreEqual("VeiligheidsoordeelIDRef", AssemblyXmlIdentifiers.TotalAssemblyResultIdRef); + + Assert.AreEqual("uom", AssemblyXmlIdentifiers.UnitOfMeasure); + Assert.AreEqual("upperCorner", AssemblyXmlIdentifiers.UpperCorner); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableAssessmentSectionAssemblyResultTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableAssessmentSectionAssemblyResultTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableAssessmentSectionAssemblyResultTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,70 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model.DataTypes; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.DataTypes +{ + [TestFixture] + public class SerializableAssessmentSectionAssemblyResultTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var assemblyResult = new SerializableAssessmentSectionAssemblyResult(); + + // Assert + Assert.AreEqual((SerializableAssemblyMethod) 0, assemblyResult.AssemblyMethod); + Assert.AreEqual((SerializableAssessmentSectionCategoryGroup) 0, assemblyResult.CategoryGroup); + Assert.AreEqual("VOLLDG", assemblyResult.Status); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentSectionAssemblyResult.AssemblyMethod), "assemblagemethode"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentSectionAssemblyResult.CategoryGroup), "categorie"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentSectionAssemblyResult.Status), "status"); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + var random = new Random(39); + var category = random.NextEnumValue(); + var assemblyMethod = random.NextEnumValue(); + + // Call + var assemblyResult = new SerializableAssessmentSectionAssemblyResult(assemblyMethod, category); + + // Assert + Assert.AreEqual(category, assemblyResult.CategoryGroup); + Assert.AreEqual(assemblyMethod, assemblyResult.AssemblyMethod); + Assert.AreEqual("VOLLDG", assemblyResult.Status); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableCombinedFailureMechanismSectionAssemblyResultTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableCombinedFailureMechanismSectionAssemblyResultTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableCombinedFailureMechanismSectionAssemblyResultTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,75 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model.DataTypes; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.DataTypes +{ + [TestFixture] + public class SerializableCombinedFailureMechanismSectionAssemblyResultTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var assemblyResult = new SerializableCombinedFailureMechanismSectionAssemblyResult(); + + // Assert + Assert.AreEqual((SerializableAssemblyMethod) 0, assemblyResult.AssemblyMethod); + Assert.AreEqual((SerializableFailureMechanismType) 0, assemblyResult.FailureMechanismType); + Assert.AreEqual((SerializableFailureMechanismSectionCategoryGroup) 0, assemblyResult.CategoryGroup); + Assert.AreEqual("VOLLDG", assemblyResult.Status); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableCombinedFailureMechanismSectionAssemblyResult.AssemblyMethod), "assemblagemethode"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableCombinedFailureMechanismSectionAssemblyResult.CategoryGroup), "categorieVak"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableCombinedFailureMechanismSectionAssemblyResult.FailureMechanismType), "typeToetsspoor"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableCombinedFailureMechanismSectionAssemblyResult.Status), "status"); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + var random = new Random(39); + var category = random.NextEnumValue(); + var failureMechanismType = random.NextEnumValue(); + var assemblyMethod = random.NextEnumValue(); + + // Call + var assemblyResult = new SerializableCombinedFailureMechanismSectionAssemblyResult(assemblyMethod, failureMechanismType, category); + + // Assert + Assert.AreEqual(assemblyMethod, assemblyResult.AssemblyMethod); + Assert.AreEqual(category, assemblyResult.CategoryGroup); + Assert.AreEqual(failureMechanismType, assemblyResult.FailureMechanismType); + Assert.AreEqual("VOLLDG", assemblyResult.Status); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismAssemblyResultTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismAssemblyResultTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismAssemblyResultTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,110 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model.DataTypes; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.DataTypes +{ + [TestFixture] + public class SerializableFailureMechanismAssemblyResultTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var assemblyResult = new SerializableFailureMechanismAssemblyResult(); + + // Assert + Assert.AreEqual((SerializableAssemblyMethod) 0, assemblyResult.AssemblyMethod); + Assert.AreEqual((SerializableFailureMechanismCategoryGroup) 0, assemblyResult.CategoryGroup); + Assert.IsNull(assemblyResult.Probability); + Assert.AreEqual("VOLLDG", assemblyResult.Status); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismAssemblyResult.AssemblyMethod), "assemblagemethode"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismAssemblyResult.CategoryGroup), "categorieTraject"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismAssemblyResult.Probability), "faalkans"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismAssemblyResult.Status), "status"); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + var random = new Random(39); + var category = random.NextEnumValue(); + var assemblyMethod = random.NextEnumValue(); + double probability = random.NextDouble(); + + // Call + var assemblyResult = new SerializableFailureMechanismAssemblyResult(assemblyMethod, category, probability); + + // Assert + Assert.AreEqual(category, assemblyResult.CategoryGroup); + Assert.AreEqual(probability, assemblyResult.Probability); + Assert.AreEqual(assemblyMethod, assemblyResult.AssemblyMethod); + Assert.AreEqual("VOLLDG", assemblyResult.Status); + } + + [Test] + [TestCase(0.5)] + [TestCase(double.NaN)] + public void ShouldSerializeProbability_WithProbabilityValues_ReturnsTrue(double probability) + { + // Setup + var random = new Random(39); + var assemblyResult = new SerializableFailureMechanismAssemblyResult( + random.NextEnumValue(), + random.NextEnumValue(), + probability); + + // Call + bool shouldSerialize = assemblyResult.ShouldSerializeProbability(); + + // Assert + Assert.IsTrue(shouldSerialize); + } + + [Test] + public void ShouldSerializeProbability_WithoutProbability_ReturnsFalse() + { + // Setup + var random = new Random(39); + var assemblyResult = new SerializableFailureMechanismAssemblyResult( + random.NextEnumValue(), + random.NextEnumValue()); + + // Call + bool shouldSerialize = assemblyResult.ShouldSerializeProbability(); + + // Assert + Assert.IsFalse(shouldSerialize); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismSectionAssemblyResultTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismSectionAssemblyResultTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismSectionAssemblyResultTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,113 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model.DataTypes; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.DataTypes +{ + [TestFixture] + public class SerializableFailureMechanismSectionAssemblyResultTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var assemblyResult = new SerializableFailureMechanismSectionAssemblyResult(); + + // Assert + Assert.AreEqual((SerializableAssemblyMethod) 0, assemblyResult.AssemblyMethod); + Assert.AreEqual((SerializableAssessmentType) 0, assemblyResult.AssessmentType); + Assert.AreEqual((SerializableFailureMechanismSectionCategoryGroup) 0, assemblyResult.CategoryGroup); + Assert.IsNull(assemblyResult.Probability); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSectionAssemblyResult.AssemblyMethod), "assemblagemethode"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSectionAssemblyResult.CategoryGroup), "categorieVak"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSectionAssemblyResult.Probability), "faalkans"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSectionAssemblyResult.AssessmentType), "toets"); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + var random = new Random(39); + var category = random.NextEnumValue(); + var assemblyMethod = random.NextEnumValue(); + var assessmentLevel = random.NextEnumValue(); + double probability = random.NextDouble(); + + // Call + var assemblyResult = new SerializableFailureMechanismSectionAssemblyResult(assemblyMethod, assessmentLevel, category, probability); + + // Assert + Assert.AreEqual(category, assemblyResult.CategoryGroup); + Assert.AreEqual(assessmentLevel, assemblyResult.AssessmentType); + Assert.AreEqual(probability, assemblyResult.Probability); + Assert.AreEqual(assemblyMethod, assemblyResult.AssemblyMethod); + } + + [Test] + [TestCase(0.5)] + [TestCase(double.NaN)] + public void ShouldSerializeProbability_WithProbabilityValues_ReturnsTrue(double probability) + { + // Setup + var random = new Random(39); + var assemblyResult = new SerializableFailureMechanismSectionAssemblyResult( + random.NextEnumValue(), + random.NextEnumValue(), + random.NextEnumValue(), + probability); + + // Call + bool shouldSerialize = assemblyResult.ShouldSerializeProbability(); + + // Assert + Assert.IsTrue(shouldSerialize); + } + + [Test] + public void ShouldSerializeProbability_WithoutProbabilityValues_ReturnsFalse() + { + // Setup + var random = new Random(39); + var assemblyResult = new SerializableFailureMechanismSectionAssemblyResult( + random.NextEnumValue(), + random.NextEnumValue(), + random.NextEnumValue()); + + // Call + bool shouldSerialize = assemblyResult.ShouldSerializeProbability(); + + // Assert + Assert.IsFalse(shouldSerialize); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableLineTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableLineTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableLineTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,76 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model.DataTypes; +using Riskeer.AssemblyTool.IO.Model.Helpers; + +namespace Riskeer.AssemblyTool.IO.Test.Model.DataTypes +{ + [TestFixture] + public class SerializableLineTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var line = new SerializableLine(); + + // Assert + Assert.IsNull(line.LineString); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableLine.LineString), "LineString", "http://www.opengis.net/gml/3.2"); + } + + [Test] + public void Constructor_GeometryNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableLine(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("geometry", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + var random = new Random(39); + var geometry = new[] + { + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()) + }; + + // Call + var line = new SerializableLine(geometry); + + // Assert + Assert.AreEqual(GeometrySerializationFormatter.Format(geometry), line.LineString.Geometry); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableMeasureTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableMeasureTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/DataTypes/SerializableMeasureTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2018. 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.Linq; +using System.Xml.Serialization; +using Core.Common.Util.Reflection; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model.DataTypes; + +namespace Riskeer.AssemblyTool.IO.Test.Model.DataTypes +{ + [TestFixture] + public class SerializableMeasureTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var measure = new SerializableMeasure(); + + // Assert + Assert.AreEqual("m", measure.UnitOfMeasure); + Assert.IsNaN(measure.Value); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableMeasure.UnitOfMeasure), "uom"); + + IEnumerable xmlTextAttributes = TypeUtils.GetPropertyAttributes( + nameof(SerializableMeasure.Value)); + Assert.AreEqual(1, xmlTextAttributes.Count()); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + double value = new Random(39).NextDouble(); + + // Call + var measure = new SerializableMeasure(value); + + // Assert + Assert.AreEqual("m", measure.UnitOfMeasure); + Assert.AreEqual(value, measure.Value); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/AssemblyXmlEnumIdentifiersTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/AssemblyXmlEnumIdentifiersTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/AssemblyXmlEnumIdentifiersTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,115 @@ +// Copyright (C) Stichting Deltares 2018. 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 NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Enums +{ + [TestFixture] + public class AssemblyXmlEnumIdentifiersTest + { + [Test] + public void AssemblyXmlEnumIdentifiers_ExpectedValues() + { + Assert.AreEqual("NVT", AssemblyXmlEnumIdentifiers.NotApplicable); + + Assert.AreEqual("I-traject", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismCategoryGroupIt); + Assert.AreEqual("II-traject", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismCategoryGroupIIt); + Assert.AreEqual("III-traject", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismCategoryGroupIIIt); + Assert.AreEqual("IV-traject", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismCategoryGroupIVt); + Assert.AreEqual("V-traject", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismCategoryGroupVt); + Assert.AreEqual("VI-traject", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismCategoryGroupVIt); + Assert.AreEqual("VII-traject", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismCategoryGroupVIIt); + + Assert.AreEqual("I-vak", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismSectionCategoryGroupIv); + Assert.AreEqual("II-vak", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismSectionCategoryGroupIIv); + Assert.AreEqual("III-vak", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismSectionCategoryGroupIIIv); + Assert.AreEqual("IV-vak", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismSectionCategoryGroupIVv); + Assert.AreEqual("V-vak", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismSectionCategoryGroupVv); + Assert.AreEqual("VI-vak", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismSectionCategoryGroupVIv); + Assert.AreEqual("VII-vak", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismSectionCategoryGroupVIIv); + + Assert.AreEqual("A+", AssemblyXmlEnumIdentifiers.SerializableAssessmentSectionCategoryGroupAPlus); + Assert.AreEqual("A", AssemblyXmlEnumIdentifiers.SerializableAssessmentSectionCategoryGroupA); + Assert.AreEqual("B", AssemblyXmlEnumIdentifiers.SerializableAssessmentSectionCategoryGroupB); + Assert.AreEqual("C", AssemblyXmlEnumIdentifiers.SerializableAssessmentSectionCategoryGroupC); + Assert.AreEqual("D", AssemblyXmlEnumIdentifiers.SerializableAssessmentSectionCategoryGroupD); + Assert.AreEqual("NGO", AssemblyXmlEnumIdentifiers.SerializableAssessmentSectionCategoryGroupNotAssessed); + + Assert.AreEqual("WBI-0E-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0E1); + Assert.AreEqual("WBI-0E-3", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0E3); + Assert.AreEqual("WBI-0G-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0G1); + Assert.AreEqual("WBI-0G-3", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0G3); + Assert.AreEqual("WBI-0G-4", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0G4); + Assert.AreEqual("WBI-0G-5", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0G5); + Assert.AreEqual("WBI-0G-6", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0G6); + Assert.AreEqual("WBI-0T-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0T1); + Assert.AreEqual("WBI-0T-3", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0T3); + Assert.AreEqual("WBI-0T-4", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0T4); + Assert.AreEqual("WBI-0T-5", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0T5); + Assert.AreEqual("WBI-0T-6", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0T6); + Assert.AreEqual("WBI-0T-7", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0T7); + Assert.AreEqual("WBI-0A-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI0A1); + Assert.AreEqual("WBI-1A-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI1A1); + Assert.AreEqual("WBI-1B-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI1B1); + Assert.AreEqual("WBI-2A-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI2A1); + Assert.AreEqual("WBI-2B-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI2B1); + Assert.AreEqual("WBI-2C-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI2C1); + Assert.AreEqual("WBI-3A-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI3A1); + Assert.AreEqual("WBI-3B-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI3B1); + Assert.AreEqual("WBI-3C-1", AssemblyXmlEnumIdentifiers.SerializableAssemblyMethodWBI3C1); + + Assert.AreEqual("GEDPROB", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismGroup1); + Assert.AreEqual("GEDSPROBEX", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismGroup2); + Assert.AreEqual("GEDSPROB", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismGroup3); + Assert.AreEqual("GEEN", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismGroup4); + + Assert.AreEqual("STBI", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeSTBI); + Assert.AreEqual("STBU", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeSTBU); + Assert.AreEqual("STPH", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeSTPH); + Assert.AreEqual("STMI", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeSTMI); + Assert.AreEqual("AGK", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeAGK); + Assert.AreEqual("AWO", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeAWO); + Assert.AreEqual("GEBU", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeGEBU); + Assert.AreEqual("GABU", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeGABU); + Assert.AreEqual("GEKB", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeGEKB); + Assert.AreEqual("GABI", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeGABI); + Assert.AreEqual("ZST", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeZST); + Assert.AreEqual("DA", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeDA); + Assert.AreEqual("HTKW", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeHTKW); + Assert.AreEqual("BSKW", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeBSKW); + Assert.AreEqual("PKW", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypePKW); + Assert.AreEqual("STKWp", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeSTKWp); + Assert.AreEqual("STKWl", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeSTKWl); + Assert.AreEqual("INN", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismTypeINN); + + Assert.AreEqual("EENVDGETS", AssemblyXmlEnumIdentifiers.SerializableAssessmentTypeSimpleAssessment); + Assert.AreEqual("GEDTETS", AssemblyXmlEnumIdentifiers.SerializableAssessmentTypeDetailedAssessment); + Assert.AreEqual("TOETSOPMT", AssemblyXmlEnumIdentifiers.SerializableAssessmentTypeTailorMadeAssessment); + Assert.AreEqual("GECBNTR", AssemblyXmlEnumIdentifiers.SerializableAssessmentTypeCombinedAssessment); + Assert.AreEqual("GECBNTRDV", AssemblyXmlEnumIdentifiers.SerializableAssessmentTypeCombinedSectionAssessment); + + Assert.AreEqual("TOETSSSTE", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismSectionTypeFailureMechanism); + Assert.AreEqual("GECBNETSSTE", AssemblyXmlEnumIdentifiers.SerializableFailureMechanismSectionTypeCombined); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableAssemblyMethodTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableAssemblyMethodTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableAssemblyMethodTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,184 @@ +// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Enums +{ + [TestFixture] + public class SerializableAssemblyMethodTest : EnumWithXmlEnumNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + SerializableAssemblyMethod.WBI0E1, 1 + }, + { + SerializableAssemblyMethod.WBI0E3, 2 + }, + { + SerializableAssemblyMethod.WBI0G1, 3 + }, + { + SerializableAssemblyMethod.WBI0G3, 4 + }, + { + SerializableAssemblyMethod.WBI0G4, 5 + }, + { + SerializableAssemblyMethod.WBI0G5, 6 + }, + { + SerializableAssemblyMethod.WBI0G6, 7 + }, + { + SerializableAssemblyMethod.WBI0T1, 8 + }, + { + SerializableAssemblyMethod.WBI0T3, 9 + }, + { + SerializableAssemblyMethod.WBI0T4, 10 + }, + { + SerializableAssemblyMethod.WBI0T5, 11 + }, + { + SerializableAssemblyMethod.WBI0T6, 12 + }, + { + SerializableAssemblyMethod.WBI0T7, 13 + }, + { + SerializableAssemblyMethod.WBI0A1, 14 + }, + { + SerializableAssemblyMethod.WBI1A1, 15 + }, + { + SerializableAssemblyMethod.WBI1B1, 16 + }, + { + SerializableAssemblyMethod.WBI2A1, 17 + }, + { + SerializableAssemblyMethod.WBI2B1, 18 + }, + { + SerializableAssemblyMethod.WBI2C1, 19 + }, + { + SerializableAssemblyMethod.WBI3A1, 20 + }, + { + SerializableAssemblyMethod.WBI3B1, 21 + }, + { + SerializableAssemblyMethod.WBI3C1, 22 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + SerializableAssemblyMethod.WBI0E1, "WBI-0E-1" + }, + { + SerializableAssemblyMethod.WBI0E3, "WBI-0E-3" + }, + { + SerializableAssemblyMethod.WBI0G1, "WBI-0G-1" + }, + { + SerializableAssemblyMethod.WBI0G3, "WBI-0G-3" + }, + { + SerializableAssemblyMethod.WBI0G4, "WBI-0G-4" + }, + { + SerializableAssemblyMethod.WBI0G5, "WBI-0G-5" + }, + { + SerializableAssemblyMethod.WBI0G6, "WBI-0G-6" + }, + { + SerializableAssemblyMethod.WBI0T1, "WBI-0T-1" + }, + { + SerializableAssemblyMethod.WBI0T3, "WBI-0T-3" + }, + { + SerializableAssemblyMethod.WBI0T4, "WBI-0T-4" + }, + { + SerializableAssemblyMethod.WBI0T5, "WBI-0T-5" + }, + { + SerializableAssemblyMethod.WBI0T6, "WBI-0T-6" + }, + { + SerializableAssemblyMethod.WBI0T7, "WBI-0T-7" + }, + { + SerializableAssemblyMethod.WBI0A1, "WBI-0A-1" + }, + { + SerializableAssemblyMethod.WBI1A1, "WBI-1A-1" + }, + { + SerializableAssemblyMethod.WBI1B1, "WBI-1B-1" + }, + { + SerializableAssemblyMethod.WBI2A1, "WBI-2A-1" + }, + { + SerializableAssemblyMethod.WBI2B1, "WBI-2B-1" + }, + { + SerializableAssemblyMethod.WBI2C1, "WBI-2C-1" + }, + { + SerializableAssemblyMethod.WBI3A1, "WBI-3A-1" + }, + { + SerializableAssemblyMethod.WBI3B1, "WBI-3B-1" + }, + { + SerializableAssemblyMethod.WBI3C1, "WBI-3C-1" + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableAssessmentSectionCategoryGroupTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableAssessmentSectionCategoryGroupTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableAssessmentSectionCategoryGroupTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,88 @@ +// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Enums +{ + [TestFixture] + public class SerializableAssessmentSectionCategoryGroupTest : EnumWithXmlEnumNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + SerializableAssessmentSectionCategoryGroup.APlus, 1 + }, + { + SerializableAssessmentSectionCategoryGroup.A, 2 + }, + { + SerializableAssessmentSectionCategoryGroup.B, 3 + }, + { + SerializableAssessmentSectionCategoryGroup.C, 4 + }, + { + SerializableAssessmentSectionCategoryGroup.D, 5 + }, + { + SerializableAssessmentSectionCategoryGroup.NotAssessed, 6 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + SerializableAssessmentSectionCategoryGroup.APlus, "A+" + }, + { + SerializableAssessmentSectionCategoryGroup.A, "A" + }, + { + SerializableAssessmentSectionCategoryGroup.B, "B" + }, + { + SerializableAssessmentSectionCategoryGroup.C, "C" + }, + { + SerializableAssessmentSectionCategoryGroup.D, "D" + }, + { + SerializableAssessmentSectionCategoryGroup.NotAssessed, "NGO" + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableAssessmentTypeTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableAssessmentTypeTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableAssessmentTypeTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,82 @@ +// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Enums +{ + [TestFixture] + public class SerializableAssessmentTypeTest : EnumWithXmlEnumNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + SerializableAssessmentType.SimpleAssessment, 1 + }, + { + SerializableAssessmentType.DetailedAssessment, 2 + }, + { + SerializableAssessmentType.TailorMadeAssessment, 3 + }, + { + SerializableAssessmentType.CombinedAssessment, 4 + }, + { + SerializableAssessmentType.CombinedSectionAssessment, 5 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + SerializableAssessmentType.SimpleAssessment, "EENVDGETS" + }, + { + SerializableAssessmentType.DetailedAssessment, "GEDTETS" + }, + { + SerializableAssessmentType.TailorMadeAssessment, "TOETSOPMT" + }, + { + SerializableAssessmentType.CombinedAssessment, "GECBNTR" + }, + { + SerializableAssessmentType.CombinedSectionAssessment, "GECBNTRDV" + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismCategoryGroupTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismCategoryGroupTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismCategoryGroupTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,100 @@ +// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Enums +{ + [TestFixture] + public class SerializableFailureMechanismCategoryGroupTest : EnumWithXmlEnumNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismCategoryGroup.NotApplicable, 1 + }, + { + SerializableFailureMechanismCategoryGroup.It, 2 + }, + { + SerializableFailureMechanismCategoryGroup.IIt, 3 + }, + { + SerializableFailureMechanismCategoryGroup.IIIt, 4 + }, + { + SerializableFailureMechanismCategoryGroup.IVt, 5 + }, + { + SerializableFailureMechanismCategoryGroup.Vt, 6 + }, + { + SerializableFailureMechanismCategoryGroup.VIt, 7 + }, + { + SerializableFailureMechanismCategoryGroup.VIIt, 8 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismCategoryGroup.NotApplicable, "NVT" + }, + { + SerializableFailureMechanismCategoryGroup.It, "I-traject" + }, + { + SerializableFailureMechanismCategoryGroup.IIt, "II-traject" + }, + { + SerializableFailureMechanismCategoryGroup.IIIt, "III-traject" + }, + { + SerializableFailureMechanismCategoryGroup.IVt, "IV-traject" + }, + { + SerializableFailureMechanismCategoryGroup.Vt, "V-traject" + }, + { + SerializableFailureMechanismCategoryGroup.VIt, "VI-traject" + }, + { + SerializableFailureMechanismCategoryGroup.VIIt, "VII-traject" + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismGroupTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismGroupTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismGroupTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,76 @@ +// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Enums +{ + [TestFixture] + public class SerializableFailureMechanismGroupTest : EnumWithXmlEnumNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismGroup.Group1, 1 + }, + { + SerializableFailureMechanismGroup.Group2, 2 + }, + { + SerializableFailureMechanismGroup.Group3, 3 + }, + { + SerializableFailureMechanismGroup.Group4, 4 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismGroup.Group1, "GEDPROB" + }, + { + SerializableFailureMechanismGroup.Group2, "GEDSPROBEX" + }, + { + SerializableFailureMechanismGroup.Group3, "GEDSPROB" + }, + { + SerializableFailureMechanismGroup.Group4, "GEEN" + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismSectionCategoryGroupTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismSectionCategoryGroupTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismSectionCategoryGroupTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,100 @@ +// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Enums +{ + [TestFixture] + public class SerializableFailureMechanismSectionCategoryGroupTest : EnumWithXmlEnumNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismSectionCategoryGroup.NotApplicable, 1 + }, + { + SerializableFailureMechanismSectionCategoryGroup.Iv, 2 + }, + { + SerializableFailureMechanismSectionCategoryGroup.IIv, 3 + }, + { + SerializableFailureMechanismSectionCategoryGroup.IIIv, 4 + }, + { + SerializableFailureMechanismSectionCategoryGroup.IVv, 5 + }, + { + SerializableFailureMechanismSectionCategoryGroup.Vv, 6 + }, + { + SerializableFailureMechanismSectionCategoryGroup.VIv, 7 + }, + { + SerializableFailureMechanismSectionCategoryGroup.VIIv, 8 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismSectionCategoryGroup.NotApplicable, "NVT" + }, + { + SerializableFailureMechanismSectionCategoryGroup.Iv, "I-vak" + }, + { + SerializableFailureMechanismSectionCategoryGroup.IIv, "II-vak" + }, + { + SerializableFailureMechanismSectionCategoryGroup.IIIv, "III-vak" + }, + { + SerializableFailureMechanismSectionCategoryGroup.IVv, "IV-vak" + }, + { + SerializableFailureMechanismSectionCategoryGroup.Vv, "V-vak" + }, + { + SerializableFailureMechanismSectionCategoryGroup.VIv, "VI-vak" + }, + { + SerializableFailureMechanismSectionCategoryGroup.VIIv, "VII-vak" + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismSectionTypeTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismSectionTypeTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismSectionTypeTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,64 @@ +// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Enums +{ + [TestFixture] + public class SerializableFailureMechanismSectionTypeTest : EnumWithXmlEnumNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismSectionType.FailureMechanism, 1 + }, + { + SerializableFailureMechanismSectionType.Combined, 2 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismSectionType.FailureMechanism, "TOETSSSTE" + }, + { + SerializableFailureMechanismSectionType.Combined, "GECBNETSSTE" + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismTypeTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismTypeTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Enums/SerializableFailureMechanismTypeTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,160 @@ +// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Enums +{ + [TestFixture] + public class SerializableFailureMechanismTypeTest : EnumWithXmlEnumNameTestFixture + { + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismType.STBI, 1 + }, + { + SerializableFailureMechanismType.STBU, 2 + }, + { + SerializableFailureMechanismType.STPH, 3 + }, + { + SerializableFailureMechanismType.STMI, 4 + }, + { + SerializableFailureMechanismType.AGK, 5 + }, + { + SerializableFailureMechanismType.AWO, 6 + }, + { + SerializableFailureMechanismType.GEBU, 7 + }, + { + SerializableFailureMechanismType.GABU, 8 + }, + { + SerializableFailureMechanismType.GEKB, 9 + }, + { + SerializableFailureMechanismType.GABI, 10 + }, + { + SerializableFailureMechanismType.ZST, 11 + }, + { + SerializableFailureMechanismType.DA, 12 + }, + { + SerializableFailureMechanismType.HTKW, 13 + }, + { + SerializableFailureMechanismType.BSKW, 14 + }, + { + SerializableFailureMechanismType.PKW, 15 + }, + { + SerializableFailureMechanismType.STKWp, 16 + }, + { + SerializableFailureMechanismType.STKWl, 17 + }, + { + SerializableFailureMechanismType.INN, 18 + } + }; + } + } + + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + SerializableFailureMechanismType.STBI, "STBI" + }, + { + SerializableFailureMechanismType.STBU, "STBU" + }, + { + SerializableFailureMechanismType.STPH, "STPH" + }, + { + SerializableFailureMechanismType.STMI, "STMI" + }, + { + SerializableFailureMechanismType.AGK, "AGK" + }, + { + SerializableFailureMechanismType.AWO, "AWO" + }, + { + SerializableFailureMechanismType.GEBU, "GEBU" + }, + { + SerializableFailureMechanismType.GABU, "GABU" + }, + { + SerializableFailureMechanismType.GEKB, "GEKB" + }, + { + SerializableFailureMechanismType.GABI, "GABI" + }, + { + SerializableFailureMechanismType.ZST, "ZST" + }, + { + SerializableFailureMechanismType.DA, "DA" + }, + { + SerializableFailureMechanismType.HTKW, "HTKW" + }, + { + SerializableFailureMechanismType.BSKW, "BSKW" + }, + { + SerializableFailureMechanismType.PKW, "PKW" + }, + { + SerializableFailureMechanismType.STKWp, "STKWp" + }, + { + SerializableFailureMechanismType.STKWl, "STKWl" + }, + { + SerializableFailureMechanismType.INN, "INN" + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Gml/SerializableBoundaryTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Gml/SerializableBoundaryTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Gml/SerializableBoundaryTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,91 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model.Gml; +using Riskeer.AssemblyTool.IO.Model.Helpers; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Gml +{ + [TestFixture] + public class SerializableBoundaryTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var boundary = new SerializableBoundary(); + + // Assert + Assert.IsNull(boundary.Envelope); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableBoundary.Envelope), "Envelope"); + } + + [Test] + public void Constructor_LowerCornerNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableBoundary(null, new Point2D(random.NextDouble(), random.NextDouble())); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("lowerCorner", exception.ParamName); + } + + [Test] + public void Constructor_UpperCornerNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableBoundary(new Point2D(random.NextDouble(), random.NextDouble()), null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("upperCorner", exception.ParamName); + } + + [Test] + public void Constructor_WithCorners_ReturnsExpectedValues() + { + // Setup + var random = new Random(39); + var lowerCorner = new Point2D(random.NextDouble(), random.NextDouble()); + var upperCorner = new Point2D(random.NextDouble(), random.NextDouble()); + + // Call + var boundary = new SerializableBoundary(lowerCorner, upperCorner); + + // Assert + Assert.AreEqual(GeometrySerializationFormatter.Format(lowerCorner), boundary.Envelope.LowerCorner); + Assert.AreEqual(GeometrySerializationFormatter.Format(upperCorner), boundary.Envelope.UpperCorner); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Gml/SerializableEnvelopeTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Gml/SerializableEnvelopeTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Gml/SerializableEnvelopeTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,94 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model.Gml; +using Riskeer.AssemblyTool.IO.Model.Helpers; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Gml +{ + [TestFixture] + public class SerializableEnvelopeTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var envelope = new SerializableEnvelope(); + + // Assert + Assert.IsNull(envelope.LowerCorner); + Assert.IsNull(envelope.UpperCorner); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableEnvelope.LowerCorner), "lowerCorner"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableEnvelope.UpperCorner), "upperCorner"); + } + + [Test] + public void Constructor_LowerCornerNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableEnvelope(null, new Point2D(random.NextDouble(), random.NextDouble())); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("lowerCorner", exception.ParamName); + } + + [Test] + public void Constructor_UpperCornerNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableEnvelope(new Point2D(random.NextDouble(), random.NextDouble()), null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("upperCorner", exception.ParamName); + } + + [Test] + public void Constructor_WithCorners_ReturnsExpectedValues() + { + // Setup + var random = new Random(39); + var lowerCorner = new Point2D(random.NextDouble(), random.NextDouble()); + var upperCorner = new Point2D(random.NextDouble(), random.NextDouble()); + + // Call + var envelope = new SerializableEnvelope(lowerCorner, upperCorner); + + // Assert + Assert.AreEqual(GeometrySerializationFormatter.Format(lowerCorner), envelope.LowerCorner); + Assert.AreEqual(GeometrySerializationFormatter.Format(upperCorner), envelope.UpperCorner); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Gml/SerializableLineStringTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Gml/SerializableLineStringTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Gml/SerializableLineStringTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model.Gml; +using Riskeer.AssemblyTool.IO.Model.Helpers; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Gml +{ + [TestFixture] + public class SerializableLineStringTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var lineString = new SerializableLineString(); + + // Assert + Assert.AreEqual("EPSG:28992", lineString.CoordinateSystem); + Assert.IsNull(lineString.Geometry); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableLineString.CoordinateSystem), "srsName"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableLineString.Geometry), "posList"); + } + + [Test] + public void Constructor_GeometryNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableLineString(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("geometry", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + var random = new Random(39); + var geometry = new[] + { + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()) + }; + + // Call + var lineString = new SerializableLineString(geometry); + + // Assert + Assert.AreEqual("EPSG:28992", lineString.CoordinateSystem); + Assert.AreEqual(GeometrySerializationFormatter.Format(geometry), lineString.Geometry); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Helpers/GeometrySerializationFormatterTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Helpers/GeometrySerializationFormatterTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Helpers/GeometrySerializationFormatterTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,104 @@ +// Copyright (C) Stichting Deltares 2018. 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.Globalization; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Helpers; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Helpers +{ + [TestFixture] + public class GeometrySerializationFormatterTest + { + [Test] + public void Format_GeometryNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GeometrySerializationFormatter.Format((IEnumerable) null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("geometry", exception.ParamName); + } + + [Test] + public void Format_GeometryEmpty_ThrowsArgumentException() + { + // Call + TestDelegate call = () => GeometrySerializationFormatter.Format(Enumerable.Empty()); + + // Assert + const string message = "Geometry cannot be empty."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message); + } + + [Test] + public void Format_WithGeometry_ReturnsFormattedString() + { + // Setup + var random = new Random(39); + var geometry = new[] + { + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()) + }; + + // Call + string formattedPoint = GeometrySerializationFormatter.Format(geometry); + + // Assert + Assert.AreEqual(geometry.Select(point => point.X.ToString(CultureInfo.InvariantCulture) + " " + point.Y.ToString(CultureInfo.InvariantCulture)) + .Aggregate((p1, p2) => p1 + " " + p2), + formattedPoint); + } + + [Test] + public void Format_PointNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GeometrySerializationFormatter.Format((Point2D) null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("point", exception.ParamName); + } + + [Test] + public void Format_WithPoint_ReturnsFormattedString() + { + // Setup + var random = new Random(39); + var point = new Point2D(random.NextDouble(), random.NextDouble()); + + // Call + string formattedPoint = GeometrySerializationFormatter.Format(point); + + // Assert + Assert.AreEqual(point.X.ToString(CultureInfo.InvariantCulture) + " " + point.Y.ToString(CultureInfo.InvariantCulture), + formattedPoint); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Helpers/SerializableIdValidatorTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Helpers/SerializableIdValidatorTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/Helpers/SerializableIdValidatorTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2018. 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 NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model.Helpers; + +namespace Riskeer.AssemblyTool.IO.Test.Model.Helpers +{ + [TestFixture] + public class SerializableIdValidatorTest + { + [Test] + [TestCase("AValidId1-2.3")] + [TestCase("_AValidId1-2.3")] + [TestCase("aValidId1-2.3")] + public void Validate_WithValidIds_ReturnsTrue(string validId) + { + // Call + bool result = SerializableIdValidator.Validate(validId); + + // Assert + Assert.IsTrue(result); + } + + [Test] + [TestCase("-invalidId1-2.3")] + [TestCase("1nvalidId1-2.3")] + [TestCase(".invalidId1-2.3")] + [TestCase("invalidId#")] + [TestCase("invalid#Id")] + [TestCase("#invalidId")] + [TestCase("i nvalidId")] + [TestCase(" invalidId")] + [TestCase("invalidId ")] + [TestCase("i\rnvalidId")] + [TestCase("\rinvalidId")] + [TestCase("invalidId\r")] + [TestCase("")] + [TestCase(" ")] + [TestCase(null)] + public void Validate_WithInvalidIds_ReturnsFalse(string invalidId) + { + // Call + bool result = SerializableIdValidator.Validate(invalidId); + + // Assert + Assert.IsFalse(result); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableAssemblyTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,399 @@ +// Copyright (C) Stichting Deltares 2018. 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.Globalization; +using System.Linq; +using System.Xml.Serialization; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using Core.Common.Util.Reflection; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model; + +namespace Riskeer.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class SerializableAssemblyTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var assembly = new SerializableAssembly(); + + // Assert + Assert.IsNull(assembly.Id); + Assert.IsNull(assembly.Boundary); + Assert.IsNull(assembly.FeatureMembers); + + object[] serializableAttributes = typeof(SerializableAssembly).GetCustomAttributes(typeof(SerializableAttribute), false); + Assert.AreEqual(1, serializableAttributes.Length); + + var xmlRootAttribute = (XmlRootAttribute) typeof(SerializableAssembly).GetCustomAttributes(typeof(XmlRootAttribute), false).Single(); + Assert.AreEqual("Assemblage", xmlRootAttribute.ElementName); + Assert.AreEqual("http://localhost/standaarden/assemblage", xmlRootAttribute.Namespace); + + const string gmlNamespace = "http://www.opengis.net/gml/3.2"; + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableAssembly.Id), "id", gmlNamespace); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssembly.Boundary), "boundedBy", gmlNamespace); + + XmlArrayAttribute xmlArrayAttribute = TypeUtils.GetPropertyAttributes(nameof(SerializableAssembly.FeatureMembers)).Single(); + Assert.AreEqual("featureMember", xmlArrayAttribute.ElementName); + + IEnumerable xmlArrayItemAttributes = TypeUtils.GetPropertyAttributes(nameof(SerializableAssembly.FeatureMembers)); + Assert.AreEqual(8, xmlArrayItemAttributes.Count()); + Assert.AreEqual(typeof(SerializableAssessmentSection), xmlArrayItemAttributes.ElementAt(0).Type); + Assert.AreEqual(typeof(SerializableAssessmentProcess), 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(SerializableCombinedFailureMechanismSectionAssembly), xmlArrayItemAttributes.ElementAt(5).Type); + Assert.AreEqual(typeof(SerializableFailureMechanismSectionCollection), xmlArrayItemAttributes.ElementAt(6).Type); + Assert.AreEqual(typeof(SerializableFailureMechanismSection), xmlArrayItemAttributes.ElementAt(7).Type); + } + + [Test] + [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))] + public void Constructor_InvalidId_ThrowsArgumentException(string invalidId) + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly(invalidId, + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + + // Assert + const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_LowerCornerNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + null, + new Point2D(random.NextDouble(), random.NextDouble()), + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("lowerCorner", exception.ParamName); + } + + [Test] + public void Constructor_UpperCornerNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + new Point2D(random.NextDouble(), random.NextDouble()), + null, + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("upperCorner", exception.ParamName); + } + + [Test] + public void Constructor_AssessmentSectionsNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + null, + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void Constructor_AssessmentProcessesNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new SerializableAssessmentSection(), + null, + new SerializableTotalAssemblyResult(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentProcess", exception.ParamName); + } + + [Test] + public void Constructor_TotalAssemblyResultsNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + null, + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("totalAssemblyResult", exception.ParamName); + } + + [Test] + public void Constructor_FailureMechanismsNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + null, + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanisms", exception.ParamName); + } + + [Test] + public void Constructor_FailureMechanismSectionAssembliesNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + Enumerable.Empty(), + null, + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionAssemblies", exception.ParamName); + } + + [Test] + public void Constructor_CombinedFailureMechanismSectionAssembliesNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + Enumerable.Empty(), + Enumerable.Empty(), + null, + Enumerable.Empty(), + Enumerable.Empty()); + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("combinedFailureMechanismSectionAssemblies", exception.ParamName); + } + + [Test] + public void Constructor_FailureMechanismSectionCollectionsNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + null, + Enumerable.Empty()); + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionCollections", exception.ParamName); + } + + [Test] + public void Constructor_FailureMechanismSectionsNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableAssembly("id", + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()), + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + null); + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSections", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "assemblyId1"; + + var random = new Random(39); + var lowerCorner = new Point2D(random.NextDouble(), random.NextDouble()); + var upperCorner = new Point2D(random.NextDouble(), random.NextDouble()); + var assessmentSection = new SerializableAssessmentSection(); + var assessmentProcess = new SerializableAssessmentProcess(); + var totalAssemblyResult = new SerializableTotalAssemblyResult(); + var failureMechanism = new SerializableFailureMechanism(); + var failureMechanismSectionAssembly = new SerializableFailureMechanismSectionAssembly(); + var combinedFailureMechanismSectionAssembly = new SerializableCombinedFailureMechanismSectionAssembly(); + var failureMechanismSections = new SerializableFailureMechanismSectionCollection(); + var failureMechanismSection = new SerializableFailureMechanismSection(); + + // Call + var assembly = new SerializableAssembly(id, + lowerCorner, + upperCorner, + assessmentSection, + assessmentProcess, + totalAssemblyResult, + new[] + { + failureMechanism + }, + new[] + { + failureMechanismSectionAssembly + }, + new[] + { + combinedFailureMechanismSectionAssembly + }, + new[] + { + failureMechanismSections + }, + new[] + { + failureMechanismSection + }); + + // Assert + Assert.AreEqual(id, assembly.Id); + 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); + CollectionAssert.AreEqual(new SerializableFeatureMember[] + { + assessmentSection, + assessmentProcess, + totalAssemblyResult, + failureMechanism, + failureMechanismSectionAssembly, + combinedFailureMechanismSectionAssembly, + failureMechanismSections, + failureMechanismSection + }, assembly.FeatureMembers); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableAssessmentProcessTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableAssessmentProcessTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableAssessmentProcessTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,112 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model; + +namespace Riskeer.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class SerializableAssessmentProcessTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var assessmentProcess = new SerializableAssessmentProcess(); + + // Assert + Assert.IsInstanceOf(assessmentProcess); + Assert.IsNull(assessmentProcess.Id); + Assert.IsNull(assessmentProcess.AssessmentSectionId); + Assert.AreEqual(2017, assessmentProcess.StartYear); + Assert.AreEqual(2023, assessmentProcess.EndYear); + + SerializableAttributeTestHelper.AssertXmlTypeAttribute(typeof(SerializableAssessmentProcess), "Beoordelingsproces"); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableAssessmentProcess.Id), "BeoordelingsprocesID"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableAssessmentProcess.AssessmentSectionId), "WaterkeringstelselIDRef"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentProcess.StartYear), "beginJaarBeoordelingsronde"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentProcess.EndYear), "eindJaarBeoordelingsronde"); + } + + [Test] + [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))] + public void Constructor_InvalidId_ThrowsArgumentException(string invalidId) + { + // Call + TestDelegate call = () => new SerializableAssessmentProcess(invalidId, + new SerializableAssessmentSection()); + + // Assert + const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableAssessmentProcess("id", + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "processId"; + + var random = new Random(39); + var assessmentSection = new SerializableAssessmentSection( + "assessmentSectionId", + "name", + new[] + { + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()) + }); + + // Call + var assessmentProcess = new SerializableAssessmentProcess(id, + assessmentSection); + + // Assert + Assert.AreEqual(id, assessmentProcess.Id); + Assert.AreEqual(assessmentSection.Id, assessmentProcess.AssessmentSectionId); + Assert.AreEqual(2017, assessmentProcess.StartYear); + Assert.AreEqual(2023, assessmentProcess.EndYear); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableAssessmentSectionTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,129 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model; + +namespace Riskeer.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class SerializableAssessmentSectionTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var assessmentSection = new SerializableAssessmentSection(); + + // Assert + Assert.IsInstanceOf(assessmentSection); + Assert.AreEqual("DKTRJCT", assessmentSection.AssessmentSectionType); + Assert.IsNull(assessmentSection.Id); + Assert.IsNull(assessmentSection.Name); + Assert.IsNull(assessmentSection.ReferenceLineGeometry); + Assert.IsNull(assessmentSection.ReferenceLineLength); + + SerializableAttributeTestHelper.AssertXmlTypeAttribute(typeof(SerializableAssessmentSection), "Waterkeringstelsel"); + + 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.ReferenceLineLength), "lengte"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableAssessmentSection.ReferenceLineGeometry), "geometrie2D"); + } + + [Test] + [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))] + public void Constructor_InvalidId_ThrowsArgumentException(string invalidId) + { + // Call + TestDelegate call = () => new SerializableAssessmentSection(invalidId, + "name", + Enumerable.Empty()); + + // Assert + const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_NameNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableAssessmentSection("id", + null, + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("name", exception.ParamName); + } + + [Test] + public void Constructor_GeometryNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableAssessmentSection("id", + "name", + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("geometry", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string name = "section name"; + const string id = "sectionId"; + + var random = new Random(39); + var geometry = new[] + { + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()) + }; + + // Call + var assessmentSection = new SerializableAssessmentSection(id, name, geometry); + + // Assert + Assert.AreEqual(id, assessmentSection.Id); + Assert.AreEqual(name, assessmentSection.Name); + Assert.AreEqual(Math2D.Length(geometry), assessmentSection.ReferenceLineLength.Value); + Assert.IsNotNull(assessmentSection.ReferenceLineGeometry); + Assert.AreEqual("DKTRJCT", assessmentSection.AssessmentSectionType); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableCombinedFailureMechanismSectionAssemblyTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableCombinedFailureMechanismSectionAssemblyTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableCombinedFailureMechanismSectionAssemblyTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,180 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model; +using Riskeer.AssemblyTool.IO.Model.DataTypes; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class SerializableCombinedFailureMechanismSectionAssemblyTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var combinedSectionAssembly = new SerializableCombinedFailureMechanismSectionAssembly(); + + // Assert + Assert.IsInstanceOf(combinedSectionAssembly); + Assert.IsNull(combinedSectionAssembly.Id); + Assert.IsNull(combinedSectionAssembly.TotalAssemblyResultId); + Assert.IsNull(combinedSectionAssembly.FailureMechanismSectionId); + Assert.IsNull(combinedSectionAssembly.CombinedSectionResult); + Assert.IsNull(combinedSectionAssembly.FailureMechanismResults); + + SerializableAttributeTestHelper.AssertXmlTypeAttribute(typeof(SerializableCombinedFailureMechanismSectionAssembly), "GecombineerdToetsoordeel"); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableCombinedFailureMechanismSectionAssembly.Id), "GecombineerdToetsoordeelID"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableCombinedFailureMechanismSectionAssembly.TotalAssemblyResultId), "VeiligheidsoordeelIDRef"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableCombinedFailureMechanismSectionAssembly.FailureMechanismSectionId), "WaterkeringsectieIDRef"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableCombinedFailureMechanismSectionAssembly.CombinedSectionResult), "toetsoordeelGecombineerd"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableCombinedFailureMechanismSectionAssembly.FailureMechanismResults), "eindtoetsoordeelToetsspoor"); + } + + [Test] + [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))] + public void Constructor_InvalidId_ThrowsArgumentException(string invalidId) + { + // Call + TestDelegate call = () => new SerializableCombinedFailureMechanismSectionAssembly(invalidId, + new SerializableTotalAssemblyResult(), + new SerializableFailureMechanismSection(), + new SerializableCombinedFailureMechanismSectionAssemblyResult[0], + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_TotalAssemblyResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableCombinedFailureMechanismSectionAssembly("id", + null, + new SerializableFailureMechanismSection(), + new SerializableCombinedFailureMechanismSectionAssemblyResult[0], + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("totalAssemblyResult", exception.ParamName); + } + + [Test] + public void Constructor_SectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableCombinedFailureMechanismSectionAssembly("id", + new SerializableTotalAssemblyResult(), + null, + new SerializableCombinedFailureMechanismSectionAssemblyResult[0], + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("section", exception.ParamName); + } + + [Test] + public void Constructor_FailureMechanismResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableCombinedFailureMechanismSectionAssembly("id", + new SerializableTotalAssemblyResult(), + new SerializableFailureMechanismSection(), + null, + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismResults", exception.ParamName); + } + + [Test] + public void Constructor_CombinedSectionResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableCombinedFailureMechanismSectionAssembly("id", + new SerializableTotalAssemblyResult(), + new SerializableFailureMechanismSection(), + new SerializableCombinedFailureMechanismSectionAssemblyResult[0], + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("combinedSectionResult", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "id"; + + var random = new Random(39); + var totalAssembly = new SerializableTotalAssemblyResult("totalAssemblyID", + new SerializableAssessmentProcess(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableAssessmentSectionAssemblyResult()); + var section = new SerializableFailureMechanismSection("sectionID", + new SerializableFailureMechanismSectionCollection(), + random.NextDouble(), + random.NextDouble(), + new[] + { + new Point2D(random.NextDouble(), random.NextDouble()) + }, + SerializableFailureMechanismSectionType.Combined); + var sectionResults = new SerializableCombinedFailureMechanismSectionAssemblyResult[0]; + var combinedSectionResult = new SerializableFailureMechanismSectionAssemblyResult(); + + // Call + var combinedSectionAssembly = new SerializableCombinedFailureMechanismSectionAssembly(id, + totalAssembly, + section, + sectionResults, + combinedSectionResult); + + // Assert + Assert.AreEqual(id, combinedSectionAssembly.Id); + Assert.AreEqual(totalAssembly.Id, combinedSectionAssembly.TotalAssemblyResultId); + Assert.AreEqual(section.Id, combinedSectionAssembly.FailureMechanismSectionId); + Assert.AreSame(sectionResults, combinedSectionAssembly.FailureMechanismResults); + Assert.AreSame(combinedSectionResult, combinedSectionAssembly.CombinedSectionResult); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionAssemblyTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionAssemblyTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionAssemblyTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,180 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model; +using Riskeer.AssemblyTool.IO.Model.DataTypes; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.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.FailureMechanismSectionId); + Assert.IsNull(sectionAssembly.CombinedSectionResult); + Assert.IsNull(sectionAssembly.SectionResults); + + SerializableAttributeTestHelper.AssertXmlTypeAttribute(typeof(SerializableFailureMechanismSectionAssembly), "Toets"); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSectionAssembly.Id), "ToetsID"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSectionAssembly.FailureMechanismId), "ToetsspoorIDRef"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSectionAssembly.FailureMechanismSectionId), "WaterkeringsectieIDRef"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSectionAssembly.CombinedSectionResult), "eindtoetsoordeel"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSectionAssembly.SectionResults), "toetsoordeelVak"); + } + + [Test] + [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))] + public void Constructor_InvalidId_ThrowsArgumentException(string invalidId) + { + // Call + TestDelegate call = () => new SerializableFailureMechanismSectionAssembly(invalidId, + new SerializableFailureMechanism(), + new SerializableFailureMechanismSection(), + new SerializableFailureMechanismSectionAssemblyResult[0], + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableFailureMechanismSectionAssembly("id", + null, + new SerializableFailureMechanismSection(), + new SerializableFailureMechanismSectionAssemblyResult[0], + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanism", exception.ParamName); + } + + [Test] + public void Constructor_SectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableFailureMechanismSectionAssembly("id", + new SerializableFailureMechanism(), + null, + new SerializableFailureMechanismSectionAssemblyResult[0], + new SerializableFailureMechanismSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("section", exception.ParamName); + } + + [Test] + public void Constructor_SectionResultsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableFailureMechanismSectionAssembly("id", + new SerializableFailureMechanism(), + new SerializableFailureMechanismSection(), + 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 SerializableFailureMechanismSection(), + new SerializableFailureMechanismSectionAssemblyResult[0], + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("combinedSectionResult", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "id"; + + var random = new Random(39); + var failureMechanism = new SerializableFailureMechanism("failureMechanismID", + new SerializableTotalAssemblyResult(), + random.NextEnumValue(), + random.NextEnumValue(), + new SerializableFailureMechanismAssemblyResult()); + var section = new SerializableFailureMechanismSection("sectionID", + new SerializableFailureMechanismSectionCollection(), + random.NextDouble(), + random.NextDouble(), + new[] + { + new Point2D(random.NextDouble(), random.NextDouble()) + }, + SerializableFailureMechanismSectionType.FailureMechanism); + var sectionResults = new SerializableFailureMechanismSectionAssemblyResult[0]; + var combinedSectionResult = new SerializableFailureMechanismSectionAssemblyResult(); + + // Call + var sectionAssembly = new SerializableFailureMechanismSectionAssembly(id, + failureMechanism, + section, + sectionResults, + combinedSectionResult); + + // Assert + Assert.AreEqual(id, sectionAssembly.Id); + Assert.AreEqual(failureMechanism.Id, sectionAssembly.FailureMechanismId); + Assert.AreEqual(section.Id, sectionAssembly.FailureMechanismSectionId); + Assert.AreSame(sectionResults, sectionAssembly.SectionResults); + Assert.AreSame(combinedSectionResult, sectionAssembly.CombinedSectionResult); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionCollectionTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionCollectionTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionCollectionTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,74 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model; + +namespace Riskeer.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class SerializableFailureMechanismSectionCollectionTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var sections = new SerializableFailureMechanismSectionCollection(); + + // Assert + Assert.IsInstanceOf(sections); + Assert.IsNull(sections.Id); + + SerializableAttributeTestHelper.AssertXmlTypeAttribute(typeof(SerializableFailureMechanismSectionCollection), "Vakindeling"); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSectionCollection.Id), "VakindelingID"); + } + + [Test] + [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))] + public void Constructor_WithInvalidId_ThrowsArgumentException(string invalidId) + { + // Call + TestDelegate call = () => new SerializableFailureMechanismSectionCollection(invalidId); + + // Assert + const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_WithValidId_ReturnsExpectedValues() + { + // Setup + const string id = "collectionId"; + + // Call + var collection = new SerializableFailureMechanismSectionCollection(id); + + // Assert + Assert.AreEqual(id, collection.Id); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismSectionTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,194 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model; +using Riskeer.AssemblyTool.IO.Model.Enums; +using Riskeer.AssemblyTool.IO.Model.Helpers; + +namespace Riskeer.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.FailureMechanismSectionCollectionId); + Assert.IsNull(section.StartDistance); + Assert.IsNull(section.EndDistance); + Assert.IsNull(section.Geometry); + Assert.AreEqual((SerializableFailureMechanismSectionType) 0, section.FailureMechanismSectionType); + + SerializableAttributeTestHelper.AssertXmlTypeAttribute(typeof(SerializableFailureMechanismSection), "ToetsVak"); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSection.Id), "id", "http://www.opengis.net/gml/3.2"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanismSection.FailureMechanismSectionCollectionId), "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"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanismSection.AssemblyMethod), "assemblagemethode"); + } + + [Test] + [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))] + public void Constructor_InvalidId_ThrowsArgumentException(string invalidId) + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableFailureMechanismSection(invalidId, + new SerializableFailureMechanismSectionCollection(), + random.NextDouble(), + random.NextDouble(), + Enumerable.Empty(), + random.NextEnumValue()); + + // Assert + const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_FailureMechanismSectionCollectionNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableFailureMechanismSection("id", + null, + random.NextDouble(), + random.NextDouble(), + Enumerable.Empty(), + random.NextEnumValue()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismSectionCollection", exception.ParamName); + } + + [Test] + public void Constructor_GeometryNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableFailureMechanismSection("id", + new SerializableFailureMechanismSectionCollection(), + random.NextDouble(), + random.NextDouble(), + null, + random.NextEnumValue()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("geometry", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "sectionId"; + + var random = new Random(39); + var sectionCollection = new SerializableFailureMechanismSectionCollection("sectionCollectionId"); + double startDistance = random.NextDouble(); + double endDistance = random.NextDouble(); + var assemblyMethod = random.NextEnumValue(); + var sectionType = random.NextEnumValue(); + var geometry = new[] + { + new Point2D(random.NextDouble(), random.NextDouble()), + new Point2D(random.NextDouble(), random.NextDouble()) + }; + + // Call + var section = new SerializableFailureMechanismSection(id, + sectionCollection, + startDistance, + endDistance, + geometry, + sectionType, + assemblyMethod); + + // Assert + Assert.AreEqual(id, section.Id); + Assert.AreEqual(sectionCollection.Id, section.FailureMechanismSectionCollectionId); + Assert.AreEqual(startDistance, section.StartDistance.Value); + Assert.AreEqual(endDistance, section.EndDistance.Value); + Assert.AreEqual(GeometrySerializationFormatter.Format(geometry), section.Geometry.LineString.Geometry); + Assert.AreEqual(Math2D.Length(geometry), section.Length.Value); + Assert.AreEqual(assemblyMethod, section.AssemblyMethod); + Assert.AreEqual(sectionType, section.FailureMechanismSectionType); + } + + [Test] + [TestCase(SerializableAssemblyMethod.WBI0A1, true)] + [TestCase(null, false)] + public void ShouldSerializeAssemblyMethod_WithAssemblyMethodValues_ReturnsExpectedValue(SerializableAssemblyMethod? assemblyMethod, bool expectedShouldSerialize) + { + // Setup + var random = new Random(39); + var section = new SerializableFailureMechanismSection("id", + new SerializableFailureMechanismSectionCollection(), + random.NextDouble(), + random.NextDouble(), + new[] + { + new Point2D(random.NextDouble(), random.NextDouble()) + }, + random.NextEnumValue(), + assemblyMethod); + + // Call + bool shouldSerialize = section.ShouldSerializeAssemblyMethod(); + + // Assert + Assert.AreEqual(expectedShouldSerialize, shouldSerialize); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableFailureMechanismTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,154 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model; +using Riskeer.AssemblyTool.IO.Model.DataTypes; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test.Model +{ + [TestFixture] + public class SerializableFailureMechanismTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var failureMechanism = new SerializableFailureMechanism(); + + // Assert + Assert.IsInstanceOf(failureMechanism); + Assert.AreEqual("DIRECT", failureMechanism.DirectFailureMechanism); + Assert.IsNull(failureMechanism.Id); + Assert.IsNull(failureMechanism.TotalAssemblyResultId); + Assert.IsNull(failureMechanism.FailureMechanismAssemblyResult); + Assert.AreEqual((SerializableFailureMechanismGroup) 0, failureMechanism.FailureMechanismGroup); + Assert.AreEqual((SerializableFailureMechanismType) 0, failureMechanism.FailureMechanismType); + + SerializableAttributeTestHelper.AssertXmlTypeAttribute(typeof(SerializableFailureMechanism), "Toetsspoor"); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanism.Id), "ToetsspoorID"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableFailureMechanism.TotalAssemblyResultId), "VeiligheidsoordeelIDRef"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanism.FailureMechanismType), "typeToetsspoor"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanism.FailureMechanismGroup), "toetsspoorGroep"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanism.DirectFailureMechanism), "typeFaalmechanisme"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableFailureMechanism.FailureMechanismAssemblyResult), "toetsoordeel"); + } + + [Test] + [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))] + public void Constructor_InvalidId_ThrowsArgumentException(string invalidId) + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableFailureMechanism(invalidId, + new SerializableTotalAssemblyResult(), + random.NextEnumValue(), + random.NextEnumValue(), + new SerializableFailureMechanismAssemblyResult()); + + // Assert + const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_TotalAssemblyResultNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableFailureMechanism("id", + null, + random.NextEnumValue(), + random.NextEnumValue(), + new SerializableFailureMechanismAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("totalAssemblyResult", exception.ParamName); + } + + [Test] + public void Constructor_FailureMechanismAssemblyResultNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + + // Call + TestDelegate call = () => new SerializableFailureMechanism("id", + new SerializableTotalAssemblyResult(), + random.NextEnumValue(), + random.NextEnumValue(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("failureMechanismAssemblyResult", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "sectionId"; + const string totalResultId = "totalResultId"; + + var random = new Random(39); + var type = random.NextEnumValue(); + var group = random.NextEnumValue(); + var assemblyResult = new SerializableFailureMechanismAssemblyResult(); + + // Call + var failureMechanism = new SerializableFailureMechanism(id, + new SerializableTotalAssemblyResult(totalResultId, + new SerializableAssessmentProcess(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableAssessmentSectionAssemblyResult()), + type, + group, + assemblyResult); + + // Assert + Assert.AreEqual(id, failureMechanism.Id); + Assert.AreEqual(totalResultId, failureMechanism.TotalAssemblyResultId); + Assert.AreEqual(type, failureMechanism.FailureMechanismType); + Assert.AreEqual(group, failureMechanism.FailureMechanismGroup); + Assert.AreEqual("DIRECT", failureMechanism.DirectFailureMechanism); + Assert.AreSame(assemblyResult, failureMechanism.FailureMechanismAssemblyResult); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableTotalAssemblyResultTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableTotalAssemblyResultTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/SerializableTotalAssemblyResultTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,166 @@ +// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.TestUtil; +using Riskeer.AssemblyTool.IO.Model; +using Riskeer.AssemblyTool.IO.Model.DataTypes; + +namespace Riskeer.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); + Assert.IsNull(totalAssemblyResult.AssessmentSectionAssemblyResult); + + SerializableAttributeTestHelper.AssertXmlTypeAttribute(typeof(SerializableTotalAssemblyResult), "Veiligheidsoordeel"); + + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableTotalAssemblyResult.Id), "VeiligheidsoordeelID"); + SerializableAttributeTestHelper.AssertXmlAttributeAttribute( + nameof(SerializableTotalAssemblyResult.AssessmentProcessId), "BeoordelingsprocesIDRef"); + + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableTotalAssemblyResult.AssemblyResultWithProbability), "toetsoordeelMetKansschatting"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableTotalAssemblyResult.AssemblyResultWithoutProbability), "toetsoordeelZonderKansschatting"); + SerializableAttributeTestHelper.AssertXmlElementAttribute( + nameof(SerializableTotalAssemblyResult.AssessmentSectionAssemblyResult), "veiligheidsoordeel"); + } + + [Test] + [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))] + public void Constructor_InvalidId_ThrowsArgumentException(string invalidId) + { + // Call + TestDelegate call = () => new SerializableTotalAssemblyResult(invalidId, + new SerializableAssessmentProcess(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableAssessmentSectionAssemblyResult()); + + // Assert + const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_AssessmentProcessNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableTotalAssemblyResult("id", + null, + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableAssessmentSectionAssemblyResult()); + + // 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(), + new SerializableAssessmentSectionAssemblyResult()); + + // 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, + new SerializableAssessmentSectionAssemblyResult()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assemblyResultWithProbability", exception.ParamName); + } + + [Test] + public void Constructor_AssessmentSectionAssemblyResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new SerializableTotalAssemblyResult("id", + new SerializableAssessmentProcess(), + new SerializableFailureMechanismAssemblyResult(), + new SerializableFailureMechanismAssemblyResult(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSectionAssemblyResult", exception.ParamName); + } + + [Test] + public void Constructor_WithValidData_ReturnsExpectedValues() + { + // Setup + const string id = "id"; + + var assessmentProcess = new SerializableAssessmentProcess("processId", + new SerializableAssessmentSection()); + var resultWithoutProbability = new SerializableFailureMechanismAssemblyResult(); + var resultWithProbability = new SerializableFailureMechanismAssemblyResult(); + var assessmentSectionResult = new SerializableAssessmentSectionAssemblyResult(); + + // Call + var totalAssemblyResult = new SerializableTotalAssemblyResult(id, + assessmentProcess, + resultWithoutProbability, + resultWithProbability, + assessmentSectionResult); + + // Assert + Assert.AreEqual(id, totalAssemblyResult.Id); + Assert.AreEqual(assessmentProcess.Id, totalAssemblyResult.AssessmentProcessId); + Assert.AreSame(resultWithoutProbability, totalAssemblyResult.AssemblyResultWithoutProbability); + Assert.AreSame(resultWithProbability, totalAssemblyResult.AssemblyResultWithProbability); + Assert.AreSame(assessmentSectionResult, totalAssemblyResult.AssessmentSectionAssemblyResult); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Properties/AssemblyInfo.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Properties/AssemblyInfo.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Properties/AssemblyInfo.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,25 @@ +// Copyright (C) Stichting Deltares 2018. 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.Reflection; + +[assembly: AssemblyTitle("Riskeer.AssemblyTool.IO.Test")] +[assembly: AssemblyProduct("Riskeer.AssemblyTool.IO.Test")] \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Riskeer.AssemblyTool.IO.Test.csproj =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Riskeer.AssemblyTool.IO.Test.csproj (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Riskeer.AssemblyTool.IO.Test.csproj (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,83 @@ + + + + {A85EB391-52B6-410C-B827-82746C618FA0} + Riskeer.AssemblyTool.IO.Test + Riskeer.AssemblyTool.IO.Test + + + + + ..\..\..\..\packages\NUnit.3.8.1\lib\net40\nunit.framework.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copying.licenseheader + + + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + + + {E344867E-9AC9-44C8-88A5-8185681679A9} + Core.Common.IO + + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Util + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + + + {b9838495-b090-4b84-a387-a8974f4f9cc4} + Riskeer.AssemblyTool.IO + + + {C7023D25-F8DF-4E3F-BF5D-A8F961CC63F7} + Ringtoets.AssemblyTool.IO.TestUtil + + + \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/SerializableAssemblyWriterTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/SerializableAssemblyWriterTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/SerializableAssemblyWriterTest.cs (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,399 @@ +// Copyright (C) Stichting Deltares 2018. 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.IO; +using System.Linq; +using System.Security.AccessControl; +using System.Text; +using System.Xml.Linq; +using System.Xml.Schema; +using System.Xml.Serialization; +using Core.Common.Base.Geometry; +using Core.Common.IO.Exceptions; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.IO.Model; +using Riskeer.AssemblyTool.IO.Model.DataTypes; +using Riskeer.AssemblyTool.IO.Model.Enums; + +namespace Riskeer.AssemblyTool.IO.Test +{ + [TestFixture] + public class SerializableAssemblyWriterTest + { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.AssemblyTool.IO, + nameof(SerializableAssemblyWriterTest)); + + [Test] + public void WriteAssembly_SerializableAssemblyNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => SerializableAssemblyWriter.WriteAssembly(null, string.Empty); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("serializableAssembly", exception.ParamName); + } + + [Test] + public void WriteAssembly_FilePathNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => SerializableAssemblyWriter.WriteAssembly(new SerializableAssembly(), null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("filePath", exception.ParamName); + } + + [Test] + public void WriteAssembly_InvalidData_ThrowsCriticalFileWriteException() + { + // Setup + string filePath = TestHelper.GetScratchPadPath(nameof(WriteAssembly_InvalidData_ThrowsCriticalFileWriteException)); + + var assembly = new SerializableAssembly( + "id", + new Point2D(0.0, 10.0), + new Point2D(10.0, 20.0), + new SerializableAssessmentSection(), + new SerializableAssessmentProcess(), + new SerializableTotalAssemblyResult(), + new[] + { + new SerializableFailureMechanism() + }, + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + + try + { + // Call + TestDelegate call = () => SerializableAssemblyWriter.WriteAssembly(assembly, filePath); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + finally + { + File.Delete(filePath); + } + } + + [Test] + [TestCase("")] + [TestCase(" ")] + [TestCase("c:\\>")] + public void WriteAssembly_FilePathInvalid_ThrowsCriticalFileWriteException(string filePath) + { + // Call + TestDelegate call = () => SerializableAssemblyWriter.WriteAssembly(new SerializableAssembly(), filePath); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + [Test] + public void WriteAssembly_FilePathTooLong_ThrowsCriticalFileWriteException() + { + // Setup + var filePath = new string('a', 249); + + // Call + TestDelegate call = () => SerializableAssemblyWriter.WriteAssembly(new SerializableAssembly(), filePath); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + + [Test] + public void WriteAssembly_InvalidDirectoryRights_ThrowsCriticalFileWriteException() + { + // Setup + const string directoryName = nameof(WriteAssembly_InvalidDirectoryRights_ThrowsCriticalFileWriteException); + string directoryPath = TestHelper.GetScratchPadPath(directoryName); + using (var disposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), directoryName)) + { + string filePath = Path.Combine(directoryPath, "test.bnd"); + disposeHelper.LockDirectory(FileSystemRights.Write); + + // Call + TestDelegate call = () => SerializableAssemblyWriter.WriteAssembly(new SerializableAssembly(), filePath); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } + + [Test] + public void WriteAssembly_FileInUse_ThrowsCriticalFileWriteException() + { + // Setup + string filePath = TestHelper.GetScratchPadPath(nameof(WriteAssembly_FileInUse_ThrowsCriticalFileWriteException)); + + using (var fileDisposeHelper = new FileDisposeHelper(filePath)) + { + fileDisposeHelper.LockFiles(); + + // Call + TestDelegate call = () => SerializableAssemblyWriter.WriteAssembly(new SerializableAssembly(), filePath); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual($"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.", exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } + + [Test] + public void WriteAssembly_ValidData_ValidFile() + { + // Setup + string filePath = TestHelper.GetScratchPadPath(nameof(WriteAssembly_ValidData_ValidFile)); + SerializableAssembly assembly = CreateSerializableAssembly(); + + try + { + // Call + SerializableAssemblyWriter.WriteAssembly(assembly, filePath); + + // Assert + Assert.IsTrue(File.Exists(filePath)); + string fileContent = File.ReadAllText(filePath); + Assert.AreEqual(GetSerializedAssembly(assembly), fileContent); + } + finally + { + File.Delete(filePath); + } + } + + [Test] + public void WriteAssembly_FullyConfiguredAssembly_ReturnsExpectedFile() + { + // Setup + SerializableAssembly assembly = CreateSerializableAssembly(); + string filePath = TestHelper.GetScratchPadPath(nameof(WriteAssembly_FullyConfiguredAssembly_ReturnsExpectedFile)); + + try + { + // Call + SerializableAssemblyWriter.WriteAssembly(assembly, filePath); + + // Assert + Assert.IsTrue(File.Exists(filePath)); + + string pathToExpectedFile = Path.Combine(testDataPath, "configuredAssembly.gml"); + string expectedXml = File.ReadAllText(pathToExpectedFile); + string actualXml = File.ReadAllText(filePath); + Assert.AreEqual(expectedXml, actualXml); + } + finally + { + File.Delete(filePath); + } + } + + [Test] + [Explicit("Use for writer validation after changes. XSD validation requires internet connection and takes about 20 seconds to complete.")] + public void GivenFullyConfiguredAssembly_WhenWrittenToFile_ThenValidFileCreated() + { + // Given + SerializableAssembly assembly = CreateSerializableAssembly(); + string filePath = TestHelper.GetScratchPadPath(nameof(GivenFullyConfiguredAssembly_WhenWrittenToFile_ThenValidFileCreated)); + + try + { + // When + SerializableAssemblyWriter.WriteAssembly(assembly, filePath); + + // Then + Assert.IsTrue(File.Exists(filePath)); + string fileContent = File.ReadAllText(filePath); + Console.WriteLine(fileContent); + + var schema = new XmlSchemaSet(); + schema.Add("http://localhost/standaarden/assemblage", Path.Combine(testDataPath, "assemblage.xsd")); + XDocument doc = XDocument.Parse(fileContent); + + string msg = string.Empty; + doc.Validate(schema, (o, e) => { msg += e.Message + Environment.NewLine; }); + if (msg == string.Empty) + { + Assert.Pass("Serialized document is valid" + Environment.NewLine); + } + else + { + Assert.Fail("Serialized document is invalid:" + Environment.NewLine + msg); + } + } + finally + { + File.Delete(filePath); + } + } + + private static SerializableAssembly CreateSerializableAssembly() + { + var assessmentSection = new SerializableAssessmentSection("section1", "Traject A", new[] + { + new Point2D(0, 0), + new Point2D(100.0, 0.0) + }); + + var assessmentProcess = new SerializableAssessmentProcess("beoordelingsproces1", + assessmentSection); + + var totalAssemblyResult = new SerializableTotalAssemblyResult( + "veiligheidsoordeel_1", + assessmentProcess, + new SerializableFailureMechanismAssemblyResult(SerializableAssemblyMethod.WBI2B1, SerializableFailureMechanismCategoryGroup.IIt), + new SerializableFailureMechanismAssemblyResult(SerializableAssemblyMethod.WBI3C1, SerializableFailureMechanismCategoryGroup.NotApplicable, 0.000124), + new SerializableAssessmentSectionAssemblyResult(SerializableAssemblyMethod.WBI2C1, SerializableAssessmentSectionCategoryGroup.B)); + + var failureMechanism = new SerializableFailureMechanism( + "toetsspoorGABI", + totalAssemblyResult, + SerializableFailureMechanismType.GABI, + SerializableFailureMechanismGroup.Group4, + new SerializableFailureMechanismAssemblyResult(SerializableAssemblyMethod.WBI1A1, SerializableFailureMechanismCategoryGroup.IIt)); + + var sections1 = new SerializableFailureMechanismSectionCollection("vakindelingGABI"); + var section1 = new SerializableFailureMechanismSection( + "vak_GABI_1", + sections1, + 0.12, + 10.23, + new[] + { + new Point2D(0.23, 0.24), + new Point2D(10.23, 10.24) + }, + SerializableFailureMechanismSectionType.FailureMechanism); + + var result = new SerializableFailureMechanismSectionAssembly( + "resultaat_GABI_1", + failureMechanism, + section1, + new[] + { + new SerializableFailureMechanismSectionAssemblyResult(SerializableAssemblyMethod.WBI0E1, + SerializableAssessmentType.SimpleAssessment, + SerializableFailureMechanismSectionCategoryGroup.IIv, 0.5), + new SerializableFailureMechanismSectionAssemblyResult(SerializableAssemblyMethod.WBI0T5, + SerializableAssessmentType.TailorMadeAssessment, + SerializableFailureMechanismSectionCategoryGroup.IIIv) + }, + new SerializableFailureMechanismSectionAssemblyResult(SerializableAssemblyMethod.WBI0A1, + SerializableAssessmentType.CombinedAssessment, + SerializableFailureMechanismSectionCategoryGroup.IIIv)); + + var sections2 = new SerializableFailureMechanismSectionCollection("vakindeling_gecombineerd"); + var section2 = new SerializableFailureMechanismSection( + "vak_gecombineerd_1", + sections2, + 0.12, + 10.23, + new[] + { + new Point2D(0.23, 0.24), + new Point2D(10.23, 10.24) + }, + SerializableFailureMechanismSectionType.Combined, + SerializableAssemblyMethod.WBI3B1); + var combinedResult = new SerializableCombinedFailureMechanismSectionAssembly( + "resultaat_gecombineerd_1", + totalAssemblyResult, + section2, + new[] + { + new SerializableCombinedFailureMechanismSectionAssemblyResult(SerializableAssemblyMethod.WBI3C1, SerializableFailureMechanismType.HTKW, SerializableFailureMechanismSectionCategoryGroup.IIIv), + new SerializableCombinedFailureMechanismSectionAssemblyResult(SerializableAssemblyMethod.WBI3C1, SerializableFailureMechanismType.STPH, SerializableFailureMechanismSectionCategoryGroup.IVv) + }, + new SerializableFailureMechanismSectionAssemblyResult(SerializableAssemblyMethod.WBI3B1, SerializableAssessmentType.CombinedSectionAssessment, SerializableFailureMechanismSectionCategoryGroup.VIv)); + + var assembly = new SerializableAssembly( + "assemblage_1", + new Point2D(12.0, 34.0), + new Point2D(56.053, 78.0002345), + assessmentSection, + assessmentProcess, + totalAssemblyResult, + new[] + { + failureMechanism + }, + new[] + { + result + }, + new[] + { + combinedResult + }, + new[] + { + sections1, + sections2 + }, + new[] + { + section1, + section2 + }); + return assembly; + } + + private static string GetSerializedAssembly(SerializableAssembly assembly) + { + var serializer = new XmlSerializer(typeof(SerializableAssembly)); + var xmlns = new XmlSerializerNamespaces(); + xmlns.Add("gml", "http://www.opengis.net/gml/3.2"); + xmlns.Add("asm", "http://localhost/standaarden/assemblage"); + + var writer = new StringWriterUtf8(); + serializer.Serialize(writer, assembly, xmlns); + return writer.ToString(); + } + + private class StringWriterUtf8 : StringWriter + { + public override Encoding Encoding + { + get + { + return Encoding.UTF8; + } + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/test-data/SerializableAssemblyWriterTest/assemblage.xsd =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/test-data/SerializableAssemblyWriterTest/assemblage.xsd (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/test-data/SerializableAssemblyWriterTest/assemblage.xsd (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,435 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Geüniformeerd oordeel over het dijktraject rekening houdend met alle + toetssporen. + + + + + + + + + + Resultaat van de veiligheidstoetsing. - voldoet aan de norm - + voldoet niet aan de norm - nader onderzoek nodig + + + + + + + + + + + + + + + + + + + + + + + + + + + + + De wijze waarop een mechanisme of een onderdeel van de waterkering wordt + beoordeeld. + + + + + + + + + Naam/code van het toetsspoor, zoals STPH (piping) + etc. + + + + + + + Groep van toetssporen gebaseerd op een onderverdeling op grond + van de beschikbare berekeningswijze en of betrekking hebben op directe of + indirecte mechanismen (FO Assemblagetool) + + + + + + + Aanduiding van het type faalmechanimse: + direct/indirect. + + + + + + + Aanduiding van het type oordeel: tussentijds / + volledig + + + + + + + + + + + + + Geheel van activiteiten gericht op het (periodiek) beoordelen of de + momentane toestand van een object voldoet aan de vigerende functionele en/of + wettelijke eisen. + + + + + + + + Jaartal begin van de beoordelingsronde. Toelichting: een + waterkeringstelsel wordt in meerdere beoordelingsrondes beoordeeld (in de + tijd). Bijvoorbeeld de beoordelingsronde die loopt van 2017 tot en met + 2023. + + + + + + + Jaartal einde van de beoordelingsronde. Toelichting: een + waterkeringstelsel wordt in meerdere beoordelingsrondes beoordeeld (in de + tijd). Bijvoorbeeld de beoordelingsronde die loopt van 2017 tot en met + 2023. + + + + + + + + + + + + + + Geen definitie in Aquo-lex Domein: goed, voldoende, onvoldoende, geen + oordeel + + + + + + + + + + + + + + + + + + + + + + + + + Gecombineerd oordeel van de toetsoordelen van de verschillende + toetssporen op (deel)vakniveau. + + + + + + + + + + + + + + + + + + + + + + + + + Deel van een waterkeringstelsel met min of meer gelijke eigenschappen (Aquo, + 'Toetsvak'). Voorbeelden: toetssectie, inspectievak, onderhoudsvak. + + + + + + + + + + + Afstand (in meters) van het begin van de sectie t.o.v. + het nulpunt van het referentiestelsel van de + waterkeringstelsel. + + + + + + + Afstand (in meters) van het einde van de sectie t.o.v. + het nulpunt van het referentiestelsel van de + waterkeringstelsel. + + + + + + Geometrische representatie van het object als lijn. + + + + + + + WaterkeringsectieType: Nadere aanduiding van het type + waterkeringsectie. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Een logisch samenhangend stelsel van waterkeringen. + + + + + + + + + Naam van het waterkeringstelsel. + + + + + + Geometrische representatie van het object als lijn of + vlak. + + + + + + + + WaterkeringstelselType: Nadere aanduiding van het type + waterkeringstelsel. + + + + + + + + Index: Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/test-data/SerializableAssemblyWriterTest/configuredAssembly.gml =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/test-data/SerializableAssemblyWriterTest/configuredAssembly.gml (revision 0) +++ Ringtoets/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/test-data/SerializableAssemblyWriterTest/configuredAssembly.gml (revision 36c991661009852eb8eed4aeb118ffc8b1c2a1f9) @@ -0,0 +1,115 @@ + + + + + 12 34 + 56.053 78.0002345 + + + + + Traject A + + + 0 0 100 0 + + + 100 + DKTRJCT + + + 2017 + 2023 + + + + WBI-2C-1 + B + VOLLDG + + + WBI-3C-1 + NVT + 0.000124 + VOLLDG + + + WBI-2B-1 + II-traject + VOLLDG + + + + GABI + GEEN + DIRECT + + WBI-1A-1 + II-traject + VOLLDG + + + + + WBI-0A-1 + GECBNTR + III-vak + + + WBI-0E-1 + EENVDGETS + II-vak + 0.5 + + + WBI-0T-5 + TOETSOPMT + III-vak + + + + + WBI-3B-1 + GECBNTRDV + VI-vak + + + WBI-3C-1 + HTKW + III-vak + VOLLDG + + + WBI-3C-1 + STPH + IV-vak + VOLLDG + + + + + + 0.12 + 10.23 + + + 0.23 0.24 10.23 10.24 + + + 14.142135623730951 + TOETSSSTE + + + 0.12 + 10.23 + + + 0.23 0.24 10.23 10.24 + + + 14.142135623730951 + GECBNETSSTE + WBI-3B-1 + + + \ No newline at end of file