Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Assembly/ExportableAssessmentSection.cs
===================================================================
diff -u -r67cc8670ea4af0a6e1b4ae607b4eb2a8014f08c8 -r39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Assembly/ExportableAssessmentSection.cs (.../ExportableAssessmentSection.cs) (revision 67cc8670ea4af0a6e1b4ae607b4eb2a8014f08c8)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Assembly/ExportableAssessmentSection.cs (.../ExportableAssessmentSection.cs) (revision 39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4)
@@ -35,6 +35,7 @@
/// Creates an instance of .
///
/// The name of the assessment section.
+ /// The id of the assessment section.
/// The geometry of the assessment section.
/// The assembly result of the assessment section.
/// The total assembly result with probability
@@ -47,8 +48,10 @@
/// of failure mechanisms belonging to this assessment section.
/// The combined section assembly results
/// of this assessment section.
- /// Thrown when any parameter is null.
+ /// Thrown when any parameter, except is null.
+ /// Thrown when is null, empty or consists only of whitespaces.
public ExportableAssessmentSection(string name,
+ string id,
IEnumerable geometry,
ExportableAssessmentSectionAssemblyResult assessmentSectionAssembly,
ExportableFailureMechanismAssemblyResultWithProbability failureMechanismAssemblyWithProbability,
@@ -62,6 +65,11 @@
throw new ArgumentNullException(nameof(name));
}
+ if (string.IsNullOrWhiteSpace(id))
+ {
+ throw new ArgumentException($@"'{nameof(id)}' must have a value.", nameof(id));
+ }
+
if (geometry == null)
{
throw new ArgumentNullException(nameof(geometry));
@@ -98,6 +106,7 @@
}
Name = name;
+ Id = id;
Geometry = geometry;
AssessmentSectionAssembly = assessmentSectionAssembly;
FailureMechanismAssemblyWithProbability = failureMechanismAssemblyWithProbability;
@@ -113,6 +122,11 @@
public string Name { get; }
///
+ /// Gets the id of the assessment section.
+ ///
+ public string Id { get; }
+
+ ///
/// Gets the geometry of the assessment section.
///
public IEnumerable Geometry { get; }
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs
===================================================================
diff -u -r7b05c7fa960ab9f62cd9de2ae661a0f24ca0756a -r39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 7b05c7fa960ab9f62cd9de2ae661a0f24ca0756a)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4)
@@ -52,7 +52,8 @@
throw new ArgumentNullException(nameof(assessmentSection));
}
- return new ExportableAssessmentSection(assessmentSection.Name,
+ return new ExportableAssessmentSection(assessmentSection.Name,
+ assessmentSection.Id,
assessmentSection.ReferenceLine.Points,
CreateExportableAssessmentSectionAssemblyResult(assessmentSection),
CreateExportableFailureMechanismAssemblyResultWithProbability(assessmentSection),
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Assembly/ExportableAssessmentSectionTest.cs
===================================================================
diff -u -r30c0356e486b018532e85b0dde94efe832cf445f -r39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Assembly/ExportableAssessmentSectionTest.cs (.../ExportableAssessmentSectionTest.cs) (revision 30c0356e486b018532e85b0dde94efe832cf445f)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Assembly/ExportableAssessmentSectionTest.cs (.../ExportableAssessmentSectionTest.cs) (revision 39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4)
@@ -23,6 +23,7 @@
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Integration.IO.Assembly;
using Ringtoets.Integration.IO.TestUtil;
@@ -44,6 +45,7 @@
// Call
TestDelegate call = () => new ExportableAssessmentSection(null,
+ "id",
geometry,
ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult(),
ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithProbability(),
@@ -58,6 +60,35 @@
}
[Test]
+ [TestCase(null)]
+ [TestCase("")]
+ [TestCase(" ")]
+ public void Constructor_InvalidId_ThrowsArgumentException(string invalidId)
+ {
+ // Setup
+ IEnumerable geometry = Enumerable.Empty();
+ IEnumerable> failureMechanismsWithProbability =
+ Enumerable.Empty>();
+ IEnumerable> failureMechanismsWithoutProbability =
+ Enumerable.Empty>();
+
+ // Call
+ TestDelegate call = () => new ExportableAssessmentSection(string.Empty,
+ invalidId,
+ geometry,
+ ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult(),
+ ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithProbability(),
+ ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithoutProbability(),
+ failureMechanismsWithProbability,
+ failureMechanismsWithoutProbability,
+ CreateCombinedSectionAssemblyCollection());
+
+ // Assert
+ const string expectedMessage = "'id' must have a value.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+
+ [Test]
public void Constructor_GeometryNull_ThrowsArgumentNullException()
{
// Setup
@@ -68,6 +99,7 @@
// Call
TestDelegate call = () => new ExportableAssessmentSection(string.Empty,
+ "id",
null,
ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult(),
ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithProbability(),
@@ -93,6 +125,7 @@
// Call
TestDelegate call = () => new ExportableAssessmentSection(string.Empty,
+ "id",
geometry,
null,
ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithProbability(),
@@ -117,6 +150,7 @@
// Call
TestDelegate call = () => new ExportableAssessmentSection(string.Empty,
+ "id",
geometry,
ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult(),
null,
@@ -142,6 +176,7 @@
// Call
TestDelegate call = () => new ExportableAssessmentSection(string.Empty,
+ "id",
geometry,
ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult(),
ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithProbability(),
@@ -165,6 +200,7 @@
// Call
TestDelegate call = () => new ExportableAssessmentSection(string.Empty,
+ "id",
geometry,
ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult(),
ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithProbability(),
@@ -187,6 +223,7 @@
// Call
TestDelegate call = () => new ExportableAssessmentSection(string.Empty,
+ "id",
geometry,
ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult(),
ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithProbability(),
@@ -212,6 +249,7 @@
// Call
TestDelegate call = () => new ExportableAssessmentSection(string.Empty,
+ "id",
geometry,
ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult(),
ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithProbability(),
@@ -231,9 +269,11 @@
public void Constructor_WithValidArguments_ExpectedValues(string name)
{
// Setup
+ const string id = "Assessment section id";
+
IEnumerable geometry = Enumerable.Empty();
ExportableAssessmentSectionAssemblyResult assessmentSectionAssembly = ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult();
- ExportableFailureMechanismAssemblyResultWithProbability failureMechanismAssemblyResultWithProbability =
+ ExportableFailureMechanismAssemblyResultWithProbability failureMechanismAssemblyResultWithProbability =
ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithProbability();
ExportableFailureMechanismAssemblyResult failureMechanismAssemblyResultWithoutProbability =
ExportableFailureMechanismAssemblyResultTestFactory.CreateResultWithoutProbability();
@@ -245,6 +285,7 @@
// Call
var assessmentSection = new ExportableAssessmentSection(name,
+ id,
geometry,
assessmentSectionAssembly,
failureMechanismAssemblyResultWithProbability,
@@ -255,6 +296,7 @@
// Assert
Assert.AreEqual(name, assessmentSection.Name);
+ Assert.AreEqual(id, assessmentSection.Id);
Assert.AreSame(geometry, assessmentSection.Geometry);
Assert.AreSame(assessmentSectionAssembly, assessmentSection.AssessmentSectionAssembly);
Assert.AreSame(failureMechanismAssemblyResultWithProbability, assessmentSection.FailureMechanismAssemblyWithProbability);
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssemblyCreatorTest.cs
===================================================================
diff -u -rf33ee67efb62e6be7e9d804bd8db91a5ebda75d7 -r39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssemblyCreatorTest.cs (.../SerializableAssemblyCreatorTest.cs) (revision f33ee67efb62e6be7e9d804bd8db91a5ebda75d7)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssemblyCreatorTest.cs (.../SerializableAssemblyCreatorTest.cs) (revision 39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4)
@@ -53,6 +53,7 @@
{
// Setup
const string assessmentSectionName = "assessmentSectionName";
+ const string assessmentSectionId = "assessmentSectionId";
IEnumerable geometry = CreateGeometry();
ExportableAssessmentSectionAssemblyResult assessmentSectionAssembly =
@@ -68,6 +69,7 @@
ExportableCombinedSectionAssemblyCollection combinedSectionAssemblyResults = CreateCombinedSectionAssemblyCollection();
var exportableAssessmentSection = new ExportableAssessmentSection(assessmentSectionName,
+ assessmentSectionId,
geometry,
assessmentSectionAssembly,
failureMechanismAssemblyResultWithProbability,
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs
===================================================================
diff -u -r345061e55dbb57efac05d56b0f9be112d6c61e56 -r39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision 345061e55dbb57efac05d56b0f9be112d6c61e56)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision 39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4)
@@ -1,4 +1,4 @@
-// Copyright (C) Stichting Deltares 2017. All rights reserved.
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of Ringtoets.
//
@@ -58,6 +58,7 @@
{
// Setup
const string name = "assessmentSectionName";
+ const string id = "assessmentSectionId";
var referenceLine = new ReferenceLine();
referenceLine.SetGeometry(new[]
@@ -69,7 +70,8 @@
var random = new Random(21);
var assessmentSection = new AssessmentSection(random.NextEnumValue())
{
- Name = name,
+ Name = name,
+ Id = id,
ReferenceLine = referenceLine
};
@@ -106,6 +108,7 @@
// Assert
Assert.AreEqual(name, exportableAssessmentSection.Name);
+ Assert.AreEqual(id, exportableAssessmentSection.Id);
CollectionAssert.AreEqual(referenceLine.Points, exportableAssessmentSection.Geometry);
ExportableFailureMechanismAssemblyResultWithProbability failureMechanismAssemblyWithProbability = exportableAssessmentSection.FailureMechanismAssemblyWithProbability;