Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/ReferenceLineContext.cs =================================================================== diff -u -r2a81f01756e227d5ce93717b21b87e8a5cd5fcbb -rb74a533c2366dfae97097acbdcf9938c8a592aa4 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/ReferenceLineContext.cs (.../ReferenceLineContext.cs) (revision 2a81f01756e227d5ce93717b21b87e8a5cd5fcbb) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/ReferenceLineContext.cs (.../ReferenceLineContext.cs) (revision b74a533c2366dfae97097acbdcf9938c8a592aa4) @@ -28,14 +28,29 @@ /// /// Presentation object for instances. /// - public class ReferenceLineContext : ObservableWrappedObjectContextBase + public class ReferenceLineContext : ObservableWrappedObjectContextBase { /// /// Initializes a new instance of the class. /// - /// The assessment section that is wrapped. - /// Thrown when is null. - public ReferenceLineContext(IAssessmentSection wrappedAssessmentSection) - : base(wrappedAssessmentSection) {} + /// The reference line that is wrapped. + /// The assessment section that the + /// belongs to. + /// Thrown when any parameter is null. + public ReferenceLineContext(ReferenceLine referenceLine, IAssessmentSection assessmentSection) + : base(referenceLine) + { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + AssessmentSection = assessmentSection; + } + + /// + /// Gets the assessment section. + /// + public IAssessmentSection AssessmentSection { get; } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/ReferenceLineContextTest.cs =================================================================== diff -u -r2d7781915c424dbd7887718775d4eb6e42a96503 -rb74a533c2366dfae97097acbdcf9938c8a592aa4 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/ReferenceLineContextTest.cs (.../ReferenceLineContextTest.cs) (revision 2d7781915c424dbd7887718775d4eb6e42a96503) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/ReferenceLineContextTest.cs (.../ReferenceLineContextTest.cs) (revision b74a533c2366dfae97097acbdcf9938c8a592aa4) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Controls.PresentationObjects; using NUnit.Framework; using Rhino.Mocks; @@ -31,20 +32,33 @@ public class ReferenceLineContextTest { [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new ReferenceLineContext(new ReferenceLine(), null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] public void Constructor_ExpectedValues() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); - assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); + var referenceLine = new ReferenceLine(); + // Call - var referenceLineContext = new ReferenceLineContext(assessmentSection); + var context = new ReferenceLineContext(referenceLine, assessmentSection); // Assert - Assert.IsInstanceOf>(referenceLineContext); - Assert.AreSame(assessmentSection, referenceLineContext.WrappedData); + Assert.IsInstanceOf>(context); + Assert.AreSame(referenceLine, context.WrappedData); + Assert.AreSame(assessmentSection, context.AssessmentSection); mocks.VerifyAll(); } }