Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismContext.cs =================================================================== diff -u -r69bae9f753011e0f962a3ffa9b3c696efe5852dd -rc9ef60f6ee1db12e78cd9471f754c345e8b8d07d --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismContext.cs (.../FailureMechanismContext.cs) (revision 69bae9f753011e0f962a3ffa9b3c696efe5852dd) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismContext.cs (.../FailureMechanismContext.cs) (revision c9ef60f6ee1db12e78cd9471f754c345e8b8d07d) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Ringtoets.Common.Data; namespace Ringtoets.Common.Forms.PresentationObjects @@ -33,12 +34,28 @@ /// /// The failure mechanism. /// The parent of . + /// Thrown when or are null. protected FailureMechanismContext(T wrappedFailureMechanism, AssessmentSectionBase parent) { + AssertInputsAreNotNull(wrappedFailureMechanism, parent); + WrappedData = wrappedFailureMechanism; Parent = parent; } + private void AssertInputsAreNotNull(T wrappedFailureMechanism, AssessmentSectionBase parent) + { + if (wrappedFailureMechanism == null) + { + throw new ArgumentNullException("wrappedFailureMechanism", "Failure mechanism cannot be null."); + } + + if (parent == null) + { + throw new ArgumentNullException("parent", "The assessment section cannot be null."); + } + } + /// /// Gets the parent of . /// Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismContextTest.cs =================================================================== diff -u -r69bae9f753011e0f962a3ffa9b3c696efe5852dd -rc9ef60f6ee1db12e78cd9471f754c345e8b8d07d --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismContextTest.cs (.../FailureMechanismContextTest.cs) (revision 69bae9f753011e0f962a3ffa9b3c696efe5852dd) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismContextTest.cs (.../FailureMechanismContextTest.cs) (revision c9ef60f6ee1db12e78cd9471f754c345e8b8d07d) @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System; +using NUnit.Framework; using Rhino.Mocks; @@ -28,6 +29,39 @@ mocks.VerifyAll(); } + [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => new SimpleFailureMechanismContext(null, assessmentSection); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("wrappedFailureMechanism", exception.ParamName); + } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var failureMechanism = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => new SimpleFailureMechanismContext(failureMechanism, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("parent", exception.ParamName); + } + + private class SimpleFailureMechanismContext : FailureMechanismContext { public SimpleFailureMechanismContext(IFailureMechanism wrappedFailureMechanism, AssessmentSectionBase parent) : base(wrappedFailureMechanism, parent) {} Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/FailureMechanismPlaceHolderContext.cs =================================================================== diff -u -r69bae9f753011e0f962a3ffa9b3c696efe5852dd -rc9ef60f6ee1db12e78cd9471f754c345e8b8d07d --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/FailureMechanismPlaceHolderContext.cs (.../FailureMechanismPlaceHolderContext.cs) (revision 69bae9f753011e0f962a3ffa9b3c696efe5852dd) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/FailureMechanismPlaceHolderContext.cs (.../FailureMechanismPlaceHolderContext.cs) (revision c9ef60f6ee1db12e78cd9471f754c345e8b8d07d) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Ringtoets.Common.Data; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Integration.Data.Placeholders; @@ -35,6 +36,7 @@ /// /// The failure mechanism. /// The parent of . + /// Thrown when or are null. public FailureMechanismPlaceHolderContext(FailureMechanismPlaceholder wrappedFailureMechanism, AssessmentSectionBase parent) : base(wrappedFailureMechanism, parent) { Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingFailureMechanismContext.cs =================================================================== diff -u -r69bae9f753011e0f962a3ffa9b3c696efe5852dd -rc9ef60f6ee1db12e78cd9471f754c345e8b8d07d --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingFailureMechanismContext.cs (.../PipingFailureMechanismContext.cs) (revision 69bae9f753011e0f962a3ffa9b3c696efe5852dd) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingFailureMechanismContext.cs (.../PipingFailureMechanismContext.cs) (revision c9ef60f6ee1db12e78cd9471f754c345e8b8d07d) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Ringtoets.Common.Data; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Piping.Data; @@ -35,6 +36,7 @@ /// /// The failure mechanism. /// The parent of . + /// Thrown when or are null. public PipingFailureMechanismContext(PipingFailureMechanism failureMechanism, AssessmentSectionBase assessmentSection) : base(failureMechanism, assessmentSection) {