Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs
===================================================================
diff -u -rd5874583519121e94ec4a9ad81381f0c197f06e6 -rf95e168752ab9e77c5521fa68c25cf86e653dbf0
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision d5874583519121e94ec4a9ad81381f0c197f06e6)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision f95e168752ab9e77c5521fa68c25cf86e653dbf0)
@@ -44,6 +44,7 @@
/// An with assembly results.
/// Thrown when
/// is null.
+ /// Thrown when no reference line is set for .
/// Thrown when assembly results cannot be created for .
public static ExportableAssessmentSection CreateExportableAssessmentSection(AssessmentSection assessmentSection)
{
@@ -52,6 +53,11 @@
throw new ArgumentNullException(nameof(assessmentSection));
}
+ if (assessmentSection.ReferenceLine == null)
+ {
+ throw new ArgumentException("reference line of assessment section cannot be null.");
+ }
+
return new ExportableAssessmentSection(assessmentSection.Name,
assessmentSection.Id,
assessmentSection.ReferenceLine.Points,
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs
===================================================================
diff -u -r39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4 -rf95e168752ab9e77c5521fa68c25cf86e653dbf0
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision 39fbcdb4cfd610d8c8dccbe1793d8f17fce156c4)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision f95e168752ab9e77c5521fa68c25cf86e653dbf0)
@@ -54,9 +54,27 @@
}
[Test]
- public void CreateExportableAssessmentSection_WithAssessmentSection_ReturnsExpectedValues()
+ public void CreateExportableAssessmentSection_WithAssessmentSectionWithoutReferenceLine_ThrowsArgumentException()
{
// Setup
+ var random = new Random(21);
+ var assessmentSection = new AssessmentSection(random.NextEnumValue());
+
+ // Call
+ TestDelegate call = () =>
+ {
+ ExportableAssessmentSectionFactory.CreateExportableAssessmentSection(assessmentSection);
+ };
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("reference line of assessment section cannot be null.", exception.Message);
+ }
+
+ [Test]
+ public void CreateExportableAssessmentSection_WithAssessmentSectionWithReferenceLine_ReturnsExpectedValues()
+ {
+ // Setup
const string name = "assessmentSectionName";
const string id = "assessmentSectionId";