Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/DataTypes/SerializableFailureMechanismAssemblyResult.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/DataTypes/SerializableFailureMechanismAssemblyResult.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Model/DataTypes/SerializableFailureMechanismAssemblyResult.cs (revision 3c6655d802e8c8a7f1b3fec37e96778fedb3f278) @@ -0,0 +1,88 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Xml.Serialization; +using Ringtoets.AssemblyTool.IO.Model.Enums; + +namespace Ringtoets.AssemblyTool.IO.Model.DataTypes +{ + /// + /// Class describing a serializable failure mechanism assembly result. + /// + public class SerializableFailureMechanismAssemblyResult + { + /// + /// Creates a new instance of . + /// + public SerializableFailureMechanismAssemblyResult() + { + Status = "VOLLDG"; + } + + /// + /// Creates a new instance of . + /// + /// The method used to assemble this result. + /// The category group of this assembly result. + /// The probability of this assembly result. + public SerializableFailureMechanismAssemblyResult(AssemblyMethod assemblyMethod, + SerializableFailureMechanismCategoryGroup categoryGroup, + double? probability = null) : this() + { + CategoryGroup = categoryGroup; + Probability = probability; + AssemblyMethod = assemblyMethod; + } + + /// + /// Gets or sets the name of the method used to assemble this result. + /// + [XmlElement(AssemblyXmlIdentifiers.AssemblyMethod)] + public AssemblyMethod AssemblyMethod { get; set; } + + /// + /// Gets or sets the category group of this assembly result. + /// + [XmlElement(AssemblyXmlIdentifiers.AssessmentSectionCategoryGroup)] + public SerializableFailureMechanismCategoryGroup CategoryGroup { get; set; } + + /// + /// Gets or sets the probability of this assembly result. + /// + [XmlElement(AssemblyXmlIdentifiers.Probability)] + public double? Probability { get; set; } + + /// + /// Gets or sets the status of this assembly result. + /// + [XmlElement(AssemblyXmlIdentifiers.Status)] + public string Status { get; set; } + + /// + /// Determines whether should be serialized. + /// + /// true if has a value, false otherwise. + public bool ShouldSerializeProbability() + { + return Probability.HasValue; + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj =================================================================== diff -u -r245fc0e0843e3ac3694436d2a9cef6504c308559 -r3c6655d802e8c8a7f1b3fec37e96778fedb3f278 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision 245fc0e0843e3ac3694436d2a9cef6504c308559) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.IO/Ringtoets.AssemblyTool.IO.csproj (.../Ringtoets.AssemblyTool.IO.csproj) (revision 3c6655d802e8c8a7f1b3fec37e96778fedb3f278) @@ -27,6 +27,7 @@ + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismAssemblyResultTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismAssemblyResultTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Model/DataTypes/SerializableFailureMechanismAssemblyResultTest.cs (revision 3c6655d802e8c8a7f1b3fec37e96778fedb3f278) @@ -0,0 +1,93 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.IO.Model.DataTypes; +using Ringtoets.AssemblyTool.IO.Model.Enums; +using Ringtoets.AssemblyTool.IO.TestUtil; + +namespace Ringtoets.AssemblyTool.IO.Test.Model.DataTypes +{ + [TestFixture] + public class SerializableFailureMechanismAssemblyResultTest + { + [Test] + public void DefaultConstructor_ReturnsDefaultValues() + { + // Call + var assemblyResult = new SerializableFailureMechanismAssemblyResult(); + + // Assert + Assert.AreEqual((AssemblyMethod) 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); + } + + [Test] + [TestCase(0.5, true)] + [TestCase(null, false)] + public void ShouldSerializeProbability_WithProbabilityValues_ReturnsExpectedValue(double? probability, bool expectedShouldSerialize) + { + // Setup + var random = new Random(39); + var assemblyResult = new SerializableFailureMechanismAssemblyResult( + random.NextEnumValue(), + random.NextEnumValue(), + probability); + + // Call + bool shouldSerialize = assemblyResult.ShouldSerializeProbability(); + + // Assert + Assert.AreEqual(expectedShouldSerialize, shouldSerialize); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj =================================================================== diff -u -r245fc0e0843e3ac3694436d2a9cef6504c308559 -r3c6655d802e8c8a7f1b3fec37e96778fedb3f278 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision 245fc0e0843e3ac3694436d2a9cef6504c308559) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.Test/Ringtoets.AssemblyTool.IO.Test.csproj (.../Ringtoets.AssemblyTool.IO.Test.csproj) (revision 3c6655d802e8c8a7f1b3fec37e96778fedb3f278) @@ -15,6 +15,7 @@ +